:root{--ink:#111827;--green:#173d2b;--paper:#fffdf7;--sand:#f3f0e7;--line:#cfc8b7;--red:#d60000;--blue:#1d4ed8;--muted:#667085}
*{box-sizing:border-box}
html{background:var(--sand);color:var(--ink);font-family:"Noto Sans JP","Yu Gothic",Meiryo,system-ui,sans-serif}
body{margin:0;min-height:100vh;display:flex;flex-direction:column}
a{color:inherit}
button,input,select{font:inherit}
button,a{touch-action:manipulation}
.site-header{background:var(--ink);color:#fff;border-bottom:4px solid #8b6a32}
.header-inner{max-width:1180px;margin:auto;padding:14px 20px;display:flex;align-items:center;justify-content:space-between;gap:24px}
.brand{font-size:20px;font-weight:900;text-decoration:none;letter-spacing:.03em}
.site-header nav{display:flex;gap:8px;align-items:center;flex-wrap:wrap;justify-content:flex-end}
.site-header nav a,.link-button{display:inline-flex;border:0;background:transparent;color:#fff;text-decoration:none;padding:9px 10px;border-radius:7px;cursor:pointer}
.site-header nav a:hover,.link-button:hover{background:#ffffff18}
.inline-form{display:inline;margin:0}
.page-shell{width:min(1180px,calc(100% - 28px));margin:0 auto;padding:28px 0 54px;flex:1}
.site-footer{text-align:center;padding:22px;color:#746b5c;font-size:13px}
.hero-card,.tournament-heading,.operator-heading{padding:38px 42px;margin-bottom:22px;background:var(--paper);border:1px solid #d9cfb7;box-shadow:0 18px 55px #1b2e2112}
.hero-card h1,.tournament-heading h1,.operator-heading h1{margin:.15em 0;font-size:clamp(2rem,6vw,4rem);line-height:1.16}
.hero-card p:not(.eyebrow){font-size:1.12rem;line-height:1.8}
.eyebrow{margin:0;color:#80622f;font-size:13px;font-weight:800;letter-spacing:.12em;text-transform:uppercase}
.card{background:#fff;padding:24px;margin-bottom:20px;border:1px solid #ddd7c9;box-shadow:0 2px 10px #1a24300d}
.card h2{margin-top:0}
.tournament-list,.match-list{display:grid;gap:8px}
.tournament-link,.match-row{display:grid;grid-template-columns:minmax(190px,1.1fr) minmax(260px,1.6fr) auto;gap:16px;align-items:center;padding:16px;border:1px solid #d5d7db;background:#fff;text-decoration:none}
.tournament-link{grid-template-columns:1fr auto}
.tournament-link:hover,.match-row:hover{border-color:var(--ink);box-shadow:0 4px 16px #11182712}
.tournament-link span,.muted{color:var(--muted);font-size:14px}
.match-label{font-weight:800}
.match-teams{text-align:center}
.match-teams b,.versus{padding:0 12px;color:#80622f}
.status{display:inline-flex;justify-content:center;min-width:72px;padding:6px 10px;border-radius:999px;background:#e5e7eb;font-size:12px;font-weight:900;white-space:nowrap}
.status-live{background:#fee2e2;color:#991b1b}
.status-complete{background:#dcfce7;color:#166534}
.status-scheduled{background:#e0e7ff;color:#3730a3}
.section-title-row,.match-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}
.section-title-row h2,.match-heading h1{margin:.2em 0}
.phase-title{margin:26px 0 10px;padding:9px 12px;background:var(--ink);color:#fff;font-size:16px}
.meta-list{display:flex;gap:18px;flex-wrap:wrap;margin:20px 0 0}
.meta-list div{display:flex;gap:7px}
.meta-list dt{font-weight:800}.meta-list dd{margin:0}
.small-button,.primary-button,.danger-button,.finish-button{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--ink);border-radius:7px;padding:9px 13px;background:#fff;text-decoration:none;cursor:pointer}
.primary-button{background:var(--green);border-color:var(--green);color:#fff;padding:11px 18px;font-weight:800}
.danger-button{border-color:#b91c1c;color:#b91c1c}
.finish-button{border-color:var(--blue);color:var(--blue)}
.breadcrumb{display:flex;gap:9px;align-items:center;margin-bottom:14px;color:var(--muted);font-size:14px}
.breadcrumb a{color:var(--ink)}
.score-card{padding:24px}
.scoreboard-scroll{overflow:auto;padding:8px 0 16px}
.scoreboard{width:660px;height:550px;margin:0 auto;display:grid;grid-template-columns:76px repeat(5,96px) 104px;grid-template-rows:30px 162px 96px 96px 166px;border-left:2px solid #222;border-top:2px solid #222;background:#fff}
.sb{border-right:2px solid #222;border-bottom:2px solid #222;position:relative;overflow:hidden;background:#fff}
.sb.head{display:flex;align-items:center;justify-content:center;font-size:16px;font-weight:900;white-space:nowrap}
.sb.team,.sb.name{display:flex;align-items:center;justify-content:center}
.sb.team span{writing-mode:vertical-rl;text-orientation:upright;font-size:25px;font-weight:900;letter-spacing:.12em}
.sb.name span{writing-mode:vertical-rl;text-orientation:mixed;font-size:24px;font-weight:900;letter-spacing:.1em}
.sb.total{display:grid;grid-template-rows:1fr 2px 1fr;align-items:center;justify-items:center;padding:12px;color:var(--red);font-size:29px}
.sb.total i{width:52px;border-top:2px solid var(--red)}
.score-items{position:relative;width:100%;height:100%;display:flex;align-items:flex-start;justify-content:center;gap:2px;flex-wrap:wrap;padding:7px 5px 20px}
.score-items .point{display:inline-flex;align-items:center;justify-content:center;min-width:30px;height:30px;font-size:20px;font-weight:900}
.score-items .foul{position:relative;top:55px;color:var(--red);font-size:15px;font-weight:900}
.score-items.bout-winner:after{content:"";position:absolute;top:7px;left:50%;width:70px;height:70px;transform:translateX(-50%);border:4px solid var(--red);border-radius:50%;pointer-events:none}
.draw-mark{position:absolute;inset:-3px 0 auto;display:flex;justify-content:center;font-size:84px;font-weight:300;line-height:1}
.operator-link{text-align:center;margin:20px 0 0}
.auth-card{max-width:520px;margin:40px auto}
.stack-form{display:grid;gap:16px}
.stack-form label{display:grid;gap:7px;font-weight:800}
.stack-form input,.stack-form select{width:100%;border:1px solid #9ca3af;border-radius:7px;padding:11px;background:#fff}
.field-error{color:#b91c1c;font-size:13px}
.messages{display:grid;gap:8px;margin-bottom:16px}
.message{padding:12px 14px;border:1px solid #b9c2cf;background:#fff;border-radius:7px}
.message.error{border-color:#fca5a5;background:#fef2f2}
.message.success{border-color:#86efac;background:#f0fdf4}
.empty-state{text-align:center;padding:38px 20px;color:var(--muted)}
.compact-operator-heading{padding-top:24px;padding-bottom:24px}
.compact-operator-heading h1{font-size:clamp(1.45rem,5vw,2.5rem)}
.bout-stack{display:grid;gap:12px}
.input-status{position:sticky;top:6px;z-index:20;min-height:24px;margin:-8px 0 8px;text-align:center;color:#166534;font-weight:800}
.input-status.is-error{color:#b91c1c}
.input-paper{background:#fff;border:1px solid #d1d5db;border-radius:10px;overflow:hidden;box-shadow:0 2px 9px #1118270d;transition:opacity .15s}
.input-paper.is-complete{border-color:#7fb68d}
.input-paper.is-saving{opacity:.62}
.input-paper-head{display:flex;align-items:center;justify-content:center;font-weight:800;font-size:18px;padding:9px;border-bottom:1px solid #222;background:#fafafa}
.input-sides{position:relative}
.draw-x{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:70px;height:70px;display:flex;align-items:center;justify-content:center;font-size:64px;font-weight:300;line-height:1;color:#111;z-index:5;pointer-events:none}
.input-side{display:grid;grid-template-columns:minmax(170px,1fr) 62px 90px;gap:10px;align-items:stretch;padding:12px;border-bottom:1px solid #ddd}
.input-side:last-of-type{border-bottom:0}
.input-team-label{grid-column:1 / -1;display:flex;align-items:center;justify-content:center;min-height:24px;margin:-2px 0 0;font-size:15px;font-weight:900;line-height:1.15;color:#111827;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.input-controls{display:grid;grid-template-columns:repeat(3,minmax(54px,1fr));grid-template-rows:repeat(2,48px);gap:6px;align-content:start}
.input-controls form{margin:0}
.input-controls button{width:100%;height:48px;font-size:21px;font-weight:800;border:1px solid #9ca3af;background:#fff;border-radius:5px;touch-action:manipulation;cursor:pointer}
.input-controls button.score-dot{color:#e00000}
.input-controls button.foul-btn{color:#e00000;font-size:20px}
.input-controls button:active{transform:scale(.97);background:#f3f4f6}
.input-controls button:disabled{opacity:.4}
.input-name-wrap{display:flex;flex-direction:column;align-items:center;justify-content:flex-start;min-height:112px;gap:6px}
.input-name{writing-mode:vertical-rl;text-orientation:mixed;display:flex;align-items:center;justify-content:center;font-size:24px;font-weight:800;letter-spacing:.12em;min-height:88px}
.input-name.absent{color:#9ca3af;font-size:18px}
.js-name-form{margin:0}
.name-change{font-size:11px;padding:4px 7px;border:1px solid #9ca3af;border-radius:6px;background:#fff;white-space:nowrap;writing-mode:horizontal-tb}
.name-change:hover{background:#f3f4f6}
.input-record{display:flex;flex-direction:column;align-items:center;justify-content:flex-start;min-height:112px;gap:3px;padding-top:2px}
.input-record .record-item{font-size:23px;font-weight:800;line-height:1.05;min-height:27px;display:flex;align-items:center;justify-content:center}
.input-record .record-item.dot{color:#e00000}
.input-record .record-item.first{border:2px solid #e00000;border-radius:50%;width:31px;height:31px}
.input-foul-count{font-size:12px;color:#666;margin-top:4px}
.input-actions{display:flex;gap:7px;justify-content:center;flex-wrap:wrap;padding:10px;border-top:1px solid #ddd}
.input-actions form{margin:0}
.input-actions button{padding:8px 14px;border-radius:7px;border:1px solid #9ca3af;background:#fff}
.input-actions .end{border-color:#2563eb;color:#1d4ed8}
.input-actions .reset{border-color:#dc2626;color:#b91c1c}
.input-side .disabled{opacity:.45;pointer-events:none}
@media(max-width:820px){
 .header-inner{align-items:flex-start;flex-direction:column;gap:8px}
 .site-header nav{justify-content:flex-start}
 .hero-card,.tournament-heading,.operator-heading{padding:28px 24px}
 .tournament-link,.match-row{grid-template-columns:1fr}
 .match-teams{text-align:left}
 .status{justify-self:start}
}
@media(max-width:560px){
 .page-shell{width:min(100% - 16px,1180px);padding-top:16px}
 .card,.score-card{padding:16px}
 .site-header nav a,.link-button{padding:7px 6px;font-size:13px}
 .section-title-row,.match-heading{flex-direction:column}
 .input-side{grid-template-columns:minmax(135px,1fr) 48px 72px;gap:6px;padding:8px}
 .input-controls{grid-template-columns:repeat(3,minmax(43px,1fr));grid-template-rows:repeat(2,46px);gap:5px}
 .input-controls button{height:46px;font-size:19px}
 .input-name{font-size:21px}
 .input-record .record-item{font-size:20px}
}

/* The supplied prototype is the visual specification. Production-only
   authentication and persistence must not change this page frame. */
html,body{margin:0;padding:0;background:#f3f4f6;color:#111;font-family:"Noto Sans JP","Yu Gothic",Meiryo,sans-serif}
body{display:block;min-height:100vh}
.app-header{background:#111827;color:#fff;padding:9px 14px;position:relative}
.app-header h1{margin:0;font-size:18px;line-height:1.25;padding-right:150px}
.app-main{max-width:1180px;margin:0 auto;padding:6px 16px 16px}
.header-session{margin:0}
.admin-entry{float:right;background:#374151;color:#fff;border:0;border-radius:7px;padding:7px 10px;font-size:12px;text-decoration:none;cursor:pointer}
.admin-badge{display:inline-block;float:right;background:#065f46;color:#fff;border-radius:7px;padding:7px 10px;margin-left:6px;font-size:12px}
#nav{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:8px}
#nav .main-nav-tab{display:flex;align-items:center;justify-content:center;box-sizing:border-box;border:0;border-radius:12px;min-height:38px;height:38px;padding:3px 10px;background:#d1d5db;color:#111;font-size:16px;font-weight:500;line-height:1.05;white-space:nowrap;text-decoration:none;touch-action:manipulation}
#nav .main-nav-tab:nth-child(1),#nav .main-nav-tab:nth-child(2),#nav .main-nav-tab:nth-child(3){flex:1 1 0;min-width:190px}
#nav .main-nav-tab.settings-tab{min-width:130px}
#nav .main-nav-tab.active{background:#111827;color:#fff}
.card{background:#fff;border-radius:12px;padding:14px;margin-bottom:14px;box-shadow:0 1px 4px #0002;border:0}
.tournament-card{border-radius:0;overflow:hidden}
.prototype-section{display:block}
.context-tabs{display:grid;grid-template-columns:repeat(3,1fr);border-top:2px solid #222;border-bottom:2px solid #222;background:#fff;margin:0;overflow:hidden}
.context-tabs .context-tab{display:flex;align-items:center;justify-content:center;box-sizing:border-box;min-height:34px;height:34px;padding:2px 5px;border:0;border-right:2px solid #222;border-radius:0;background:#fff;color:#111;font-size:14px;font-weight:800;line-height:1.05;white-space:nowrap;text-decoration:none;cursor:pointer}
.context-tabs .context-tab:last-child{border-right:0}
.context-tabs .context-tab.active{background:#111827;color:#fff}
.context-tabs.phase-context-tabs{grid-template-columns:repeat(3,1fr);border-top:0;border-bottom:2px solid #222}
.context-tabs.phase-context-tabs.two-tabs{grid-template-columns:1fr 1fr}
.public-match-selector{margin:10px 0 14px}
.public-match-select{display:block;width:100%;max-width:900px;height:32px;min-height:32px;margin:0 auto;border:1px solid #9ca3af;border-radius:6px;background:#fff;color:#111;padding:2px 36px 2px 10px;font-size:14px;font-weight:700;line-height:1.1}
.input-match-heading{display:flex;align-items:center;justify-content:center;gap:14px;margin:6px 0 8px;padding:4px 8px;font-size:17px;font-weight:800;white-space:nowrap}
.input-match-heading .team{min-width:0;overflow:hidden;text-overflow:ellipsis}
.input-match-heading .vs{flex:0 0 auto}
.input-paper{margin:12px 0;box-shadow:none}
.input-paper.is-complete{border-color:#d1d5db}
.input-status{position:fixed;right:10px;bottom:10px;top:auto;z-index:20;min-height:0;margin:0;padding:5px 9px;border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #0002;font-size:12px}
.prototype-panel{padding:14px;background:#fff}
.prototype-list{display:grid;gap:10px}
.prototype-match-link{display:grid;grid-template-columns:minmax(140px,1fr) minmax(220px,1.5fr) auto;gap:10px;align-items:center;border:1px solid #ddd;border-radius:10px;background:#fff;padding:12px;color:#111;text-decoration:none}
.settings-panel{display:block}
.prelim-grid{display:flex;flex-direction:column;gap:22px}
.league-card{border:1px solid #bbb;border-radius:8px;padding:12px;background:#fff}
.league-card-title{margin:0 0 8px;font-size:17px}
.prelim-block{display:grid;grid-template-columns:minmax(250px,1fr) minmax(250px,1fr);gap:20px;align-items:center}
.league-visual{position:relative;height:205px;background:#fff}
.league-visual svg{width:100%;height:100%;display:block;overflow:visible}
.league-edge{stroke:#111;stroke-width:4;fill:none;pointer-events:none;stroke-linecap:round;transition:stroke .12s,stroke-width .12s}
.league-edge-hit{stroke:transparent;stroke-width:18;fill:none;cursor:pointer}
.league-visual a:hover + .league-edge,.league-visual a:focus + .league-edge{stroke:#e00000;stroke-width:6}
.league-label{font-size:16px;font-weight:700;fill:#111;pointer-events:none}
.league-label.top{text-anchor:middle}
.league-label.left{text-anchor:end}
.league-label.right{text-anchor:start}
.league-table{width:100%;border-collapse:collapse;background:#fff;table-layout:fixed}
.league-table th,.league-table td{border:1px solid #999;padding:7px 8px;text-align:center;height:44px;box-sizing:border-box;vertical-align:middle}
.league-table th{font-weight:700;background:#fafafa;height:42px}
.league-table th:nth-child(1),.league-table td:nth-child(1){width:48%;text-align:center}
.league-table th:nth-child(2),.league-table td:nth-child(2),.league-table th:nth-child(3),.league-table td:nth-child(3),.league-table th:nth-child(4),.league-table td:nth-child(4),.league-table th:nth-child(5),.league-table td:nth-child(5){width:13%}
.league-table td:first-child{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

@media(max-width:760px){
 .app-header{padding:8px 10px}
 .app-header h1{font-size:16px;padding-right:145px}
 .app-main{padding:5px 8px 10px}
 #nav{gap:6px;margin-bottom:6px}
 #nav .main-nav-tab{min-height:34px;height:34px;padding:2px 6px;font-size:14px;border-radius:10px}
 #nav .main-nav-tab:nth-child(1),#nav .main-nav-tab:nth-child(2),#nav .main-nav-tab:nth-child(3),#nav .main-nav-tab.settings-tab{min-width:0;flex:1 1 calc(50% - 5px)}
 .prototype-match-link{grid-template-columns:1fr}
 .prelim-block{grid-template-columns:1fr;gap:10px}
 .league-visual{height:205px}
 .league-table{font-size:14px}
 .league-table th,.league-table td{height:42px;padding:6px 5px}
}
@media(max-width:600px){
 .context-tabs .context-tab{min-height:32px;height:32px;padding:1px 3px;font-size:13px}
 .input-match-heading{gap:8px;font-size:15px}
}
