@page { size: A4; margin: 0; }

:root{
  --sheet-w: 210mm;
  --sheet-h: 297mm;
  --toolbar-offset: 60px;
  
  /* Modern HSL colors for UI */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-main: radial-gradient(circle at 50% 0%, #f8fafc 0%, #cbd5e1 100%);
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  
  --home-color: #1e3a8a;
  --home-light: #eff6ff;
  --home-border: #bfdbfe;
  
  --away-color: #374151;
  --away-light: #f3f4f6;
  --away-border: #d1d5db;
}

html, body {
  margin: 0;
  padding: 0;
  background: #cbd5e1;
  background-image: radial-gradient(circle at 50% 0%, #f1f5f9 0%, #cbd5e1 100%);
  background-attachment: fixed;
  font-family: 'Inter', 'Noto Sans JP', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-primary);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  overflow-x: hidden;
}

[x-cloak] { display: none !important; }

.app-toolbar{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10050;
  background: rgba(15,23,42,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #e5e7eb;
  padding: 10px 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  box-sizing: border-box;
  max-width: 100vw;
}

.toolbar-left,
.toolbar-center,
.toolbar-right{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.toolbar-left{
  justify-self: start;
}

.toolbar-center{
  justify-self: center;
}

.toolbar-right{
  justify-self: end;
}

.toolbar-input-group{
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 9999px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

/* ---- Toolbar responsive ---- */
@media (max-width: 1100px) {
  :root{
    --toolbar-offset: 108px;
  }

  .app-toolbar{
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "toolbar-left toolbar-right"
      "toolbar-center toolbar-center";
    gap: 8px;
    padding: 8px 10px;
  }

  .toolbar-left{ grid-area: toolbar-left; }
  .toolbar-center{
    grid-area: toolbar-center;
    justify-self: stretch;
    justify-content: center;
  }
  .toolbar-right{
    grid-area: toolbar-right;
    justify-content: flex-end;
  }

  .toolbar-input-group{
    border-radius: 14px;
  }
}

@media (max-width: 900px) {
  .toolbar-input-group{
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 12px;
    gap: 4px;
    padding: 4px;
  }

  .toolbar-input-group .btn-label--long{
    display: none;
  }

  .toolbar-input-group .btn-label--short{
    display: inline;
  }
}

@media (max-width: 720px) {
  :root{
    --toolbar-offset: 130px;
  }

  .app-toolbar{
    grid-template-columns: 1fr;
    grid-template-areas:
      "toolbar-left"
      "toolbar-center"
      "toolbar-right";
  }

  .toolbar-left,
  .toolbar-center,
  .toolbar-right{
    justify-self: stretch;
    justify-content: center;
  }

  .app-toolbar .btn{
    padding: 5px 10px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  :root{
    --toolbar-offset: 140px;
  }
}

.badge{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 4px 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 9999px;
  white-space: nowrap;
  font-size: 11px;
  color: #cbd5e1;
}

.btn{
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(30,41,59,0.7);
  color: #e5e7eb;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover{
  background: rgba(30,41,59,0.95);
  border-color: rgba(255,255,255,0.25);
  transform: translateY(-1px);
}

.btn.is-active{
  background: #ffffff;
  border-color: #ffffff;
  color: #0f172a;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(255,255,255,0.18);
}

.btn.is-active:hover{
  background: #f8fafc;
  border-color: #ffffff;
}

.btn:active{
  transform: translateY(0);
}

.btn.primary{
  background: linear-gradient(135deg,#2563eb,#1d4ed8);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn.primary:hover{
  background: linear-gradient(135deg,#3b82f6,#2563eb);
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn.needs-input{
  border: 1px solid rgba(129, 140, 248, 0.35);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.22), rgba(79, 70, 229, 0.12));
  color: #e0e7ff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
}

.btn.needs-input::before{
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 6px;
  border-radius: 50%;
  background: #a5b4fc;
  box-shadow: 0 0 6px rgba(165, 180, 252, 0.7);
  vertical-align: middle;
  transform: translateY(-1px);
}

.btn.needs-input:hover{
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.32), rgba(79, 70, 229, 0.2));
  border-color: rgba(165, 180, 252, 0.55);
  color: #f8fafc;
  transform: translateY(-1px);
}

.btn.needs-input:active{
  transform: translateY(0);
}

.btn.needs-input.needs-input-flash{
  animation: needs-input-flash-btn 1.4s ease-in-out infinite;
  transition: none;
}

.btn.needs-input.needs-input-flash:hover{
  animation: needs-input-flash-btn 1.4s ease-in-out infinite;
  transition: none;
}

.btn.needs-input.needs-input-flash::before{
  animation: needs-input-flash-dot 1.4s ease-in-out infinite;
}

@keyframes needs-input-flash-btn{
  0%, 100%{
    border-color: rgba(129, 140, 248, 0.35);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.22), rgba(79, 70, 229, 0.12));
  }
  50%{
    border-color: rgba(196, 181, 253, 0.95);
    box-shadow: 0 0 14px 3px rgba(129, 140, 248, 0.55), 0 0 24px 6px rgba(99, 102, 241, 0.25);
    background: linear-gradient(180deg, rgba(129, 140, 248, 0.42), rgba(99, 102, 241, 0.28));
  }
}

@keyframes needs-input-flash-dot{
  0%, 100%{
    opacity: 0.55;
    transform: translateY(-1px) scale(1);
    box-shadow: 0 0 6px rgba(165, 180, 252, 0.7);
  }
  50%{
    opacity: 1;
    transform: translateY(-1px) scale(1.35);
    box-shadow: 0 0 10px rgba(196, 181, 253, 1);
  }
}

.game-progress-item.needs-input-flash:not(.active){
  animation: needs-input-flash-progress 1.4s ease-in-out infinite;
  transition: none;
}

@keyframes needs-input-flash-progress{
  0%, 100%{
    border-color: #f97316;
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.15);
    background: #fff7ed;
  }
  50%{
    border-color: #ea580c;
    box-shadow: 0 0 12px 3px rgba(249, 115, 22, 0.45), 0 0 20px 5px rgba(234, 88, 12, 0.2);
    background: #ffedd5;
  }
}

.btn-label--short{
  display: none;
}

.page{
  margin-top: 16px;
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 16px;
  overflow-x: auto;
}

.sheet{
  position: relative;
  width: var(--sheet-w);
  height: var(--sheet-h);
  margin: 0 auto;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: var(--sheet-w) var(--sheet-h);
  box-shadow: 0 0 12px rgba(0,0,0,0.35);
  overflow: hidden;
  user-select: none;
}

.overlay{
  position: absolute;
  inset: 0;
  transform: translate(var(--ox,0mm), var(--oy,0mm));
  pointer-events: none;
}

.field{
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  font-weight: 800;
  font-size: 11px;
  line-height: 1;
  --fty: 0mm;
  --gty: 0mm;
  --ty: calc(var(--gty) + var(--fty));
}

.field > span{
  display: inline-block;
  transform: translateY(var(--ty));
}

.shape-layer{
  position: absolute;
  inset: 0;
  transform: translate(var(--ox,0mm), var(--oy,0mm));
  pointer-events: none;
}

.shape-item{
  position: absolute;
  box-sizing: border-box;
  pointer-events: none;
}

.shape-text{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-weight: 800;
  white-space: nowrap;
}

.text-left{
  justify-content: flex-start;
  padding-left: 2mm;
}

.text-center{
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
  text-align: center;
}

.text-lg{ font-size: 16px; }
.text-xs{ font-size: 8px; }
.mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.debug .field{
  border: 1px solid rgba(239,68,68,0.6);
  background: rgba(255,255,0,0.08);
}

.link-overlay{
  position: absolute;
  inset: 0;
  transform: translate(var(--ox,0mm), var(--oy,0mm));
  pointer-events: none;
  z-index: 3;
}

.sheet-link{
  position: absolute;
  pointer-events: auto;
  border: 0;
  background: rgba(255,255,255,0.001);
  cursor: pointer;
  border-radius: 1.5mm;
}

.sheet-link:hover{
  background: rgba(59,130,246,0.06);
  box-shadow: inset 0 0 0 1px rgba(59,130,246,0.35);
}

.edit-overlay{
  position: absolute;
  inset: 0;
  transform: translate(var(--ox,0mm), var(--oy,0mm));
  pointer-events: none;
}

.hotspot{
  position: absolute;
  pointer-events: auto;
  border: 0;
  background: rgba(255,255,255,0.001);
  cursor: pointer;
  padding: 0;
  margin: 0;
  border-radius: 1.5mm;
}

.hotspot:hover{
  background: rgba(59,130,246,0.08);
  box-shadow: inset 0 0 0 1px rgba(59,130,246,0.45);
}

.hotspot--toggle.is-on{
  background: rgba(17,24,39,0.16);
  box-shadow: inset 0 0 0 1px rgba(17,24,39,0.55);
}

.debug .hotspot{
  outline: 1px dashed rgba(37,99,235,0.65);
}

.crosshair{
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.vline, .hline{
  position: absolute;
  background: rgba(0,140,255,0.6);
}

.vline{ width: 1px; top: 0; bottom: 0; }
.hline{ height: 1px; left: 0; right: 0; }

.dot{
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  transform: translate(-50%, -50%);
  background: rgba(0,140,255,0.9);
  border: 1px solid #fff;
}

.editor-pop{
  position: fixed;
  z-index: 10100;
  width: min(320px, calc(100vw - 20px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: rgba(15,23,42,0.95);
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  padding: 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.editor-pop .label{
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 10px;
  color: #f1f5f9;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

.editor-pop input,
.editor-pop select,
.editor-pop textarea{
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  transition: all 0.2s;
}

.editor-pop input:focus,
.editor-pop select:focus,
.editor-pop textarea:focus{
  border-color: #3b82f6;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.editor-pop select:disabled {
  background: rgba(255, 255, 255, 0.02);
  color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.08);
  cursor: not-allowed;
}

.editor-pop select option,
select option {
  background-color: #1e293b;
  color: #ffffff;
}

.editor-pop .row{
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.editor-pop.score-quick-pop{
  width: min(380px, calc(100vw - 20px));
}

.editor-pop.foul-quick-pop{
  width: min(420px, calc(100vw - 20px));
}

.score-quick-form{
  min-width: 360px;
}

.foul-quick-form{
  min-width: 390px;
}

.score-quick-grid{
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(150px, 1.1fr);
  gap: 10px;
}

.foul-quick-grid{
  display: grid;
  grid-template-columns: minmax(130px, 0.9fr) minmax(180px, 1.1fr);
  gap: 10px;
}

.score-quick-field,
.foul-quick-field{
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.score-quick-field span,
.foul-quick-field span{
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.score-quick-points{
  grid-column: 1 / -1;
}

.foul-quick-wide{
  grid-column: 1 / -1;
}

.score-choice-group{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.score-choice{
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  border-radius: 10px;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}

.score-choice:hover{
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.score-choice.active{
  background: linear-gradient(135deg,#2563eb,#1d4ed8);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.quick-modal-actions{
  justify-content: flex-end;
}

.quick-modal-actions .btn2{
  min-width: 72px;
}

@media (max-width: 420px){
  .score-quick-form{
    min-width: 0;
  }

  .foul-quick-form{
    min-width: 0;
  }

  .score-quick-grid{
    grid-template-columns: 1fr;
  }

  .foul-quick-grid{
    grid-template-columns: 1fr;
  }

  .score-quick-points{
    grid-column: auto;
  }

  .foul-quick-wide{
    grid-column: auto;
  }

  .score-choice-group{
    grid-template-columns: 1fr;
  }
}

.editor-pop .btn2,
.pill{
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.editor-pop .btn2:hover,
.pill:hover{
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.editor-pop .btn2.primary{
  background: linear-gradient(135deg,#2563eb,#1d4ed8);
  border-color: transparent;
  color: #ffffff;
}

.editor-pop .btn2.primary:hover{
  background: linear-gradient(135deg,#3b82f6,#2563eb);
}

.sheet-drawer-backdrop{
  position: fixed;
  inset: 0;
  z-index: 10100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.28), transparent 34%),
    rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sheet-drawer{
  width: min(980px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: #ffffff;
  color: #111827;
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.38);
  padding: 20px;
}

.sheet-drawer-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e5e7eb;
}

.sheet-drawer-title{
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.sheet-drawer-subtitle{
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.sheet-drawer h3{
  font-size: 14px;
  font-weight: 900;
  margin: 0 0 10px;
  color: #334155;
}

.sheet-drawer input,
.sheet-drawer select,
.sheet-drawer textarea{
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
}

.sheet-drawer input::placeholder,
.sheet-drawer textarea::placeholder{
  color: #94a3b8;
  font-weight: 500;
  opacity: 1;
}

.sheet-drawer input::-webkit-input-placeholder,
.sheet-drawer textarea::-webkit-input-placeholder{
  color: #94a3b8;
  font-weight: 500;
  opacity: 1;
}

.sheet-drawer input::-moz-placeholder,
.sheet-drawer textarea::-moz-placeholder{
  color: #94a3b8;
  font-weight: 500;
  opacity: 1;
}

.roster-table input::placeholder{
  color: #94a3b8;
  font-weight: 500;
  opacity: 1;
}

.sheet-drawer input:focus,
.sheet-drawer select:focus,
.sheet-drawer textarea:focus{
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.sheet-drawer select:disabled{
  background: #eef2f7;
  color: #94a3b8;
  border-color: #cbd5e1;
}

.sheet-drawer select option{
  background-color: #ffffff;
  color: #0f172a;
}

.setup-modal-backdrop{
  position: fixed;
  inset: 0;
  z-index: 10110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.28), transparent 34%),
    rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.setup-modal{
  width: min(900px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: #ffffff;
  color: #111827;
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.38);
  padding: 20px;
}

.setup-modal-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e5e7eb;
}

.setup-modal-title{
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.setup-modal-subtitle{
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.setup-close-btn,
.setup-save-btn{
  border: 0;
  border-radius: 9999px;
  cursor: pointer;
  font-weight: 900;
  transition: all 0.2s;
}

.setup-close-btn{
  background: #f1f5f9;
  color: #334155;
  padding: 8px 14px;
}

.setup-close-btn:hover{
  background: #e2e8f0;
}

.setup-form-grid{
  display: grid;
  grid-template-columns: 1.25fr 0.8fr 1fr;
  gap: 12px;
}

.setup-field{
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.setup-field-wide{
  grid-column: span 2;
}

.setup-field span{
  color: #475569;
  font-size: 12px;
  font-weight: 900;
}

.setup-field input{
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  outline: none;
  transition: all 0.2s;
}

.setup-field input:focus{
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.setup-field input[readonly]{
  background: #eef2f7;
  color: #64748b;
  cursor: not-allowed;
}

.setup-modal-actions{
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.setup-save-btn{
  background: linear-gradient(135deg,#2563eb,#1d4ed8);
  color: #ffffff;
  padding: 10px 18px;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

.setup-save-btn:hover{
  background: linear-gradient(135deg,#3b82f6,#2563eb);
  transform: translateY(-1px);
}

.section{
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.sheet-drawer .section{
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 14px;
  padding: 14px;
}

.grid2{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.grid3{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.roster-team{
  container-type: inline-size;
  container-name: roster-team;
}

@container roster-team (max-width: 640px){
  .roster-table{
    display: block;
  }

  .roster-table thead{
    display: none;
  }

  .roster-table tbody{
    display: block;
  }

  .roster-table tbody tr{
    display: grid;
    grid-template-columns: 72px 1fr;
    grid-template-areas:
      "name name"
      "no license";
    gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
  }

  .roster-table tbody tr:hover td{
    background-color: transparent;
  }

  .roster-table td{
    display: block;
    padding: 0;
    border: none;
  }

  .roster-table td:nth-child(1){
    grid-area: no;
  }

  .roster-table td:nth-child(2){
    grid-area: name;
  }

  .roster-table td:nth-child(3){
    grid-area: license;
  }
}

.pill{
  border-radius: 9999px;
  font-size: 12px;
  padding: 6px 14px;
}

.pill.active{
  background: #2563eb;
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

/* Table Style in Event Log */
table{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td{
  border-bottom: 1px solid var(--border-color);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

th{
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tr:hover td{
  background-color: #f8fafc;
}

.sheet-drawer tr:hover td{
  background-color: #f8fafc;
}

.sheet-drawer th{
  color: #475569;
  border-bottom-color: #cbd5e1;
}

.sheet-drawer td{
  border-bottom-color: #e5e7eb;
}

.sheet-drawer .pill{
  border: 0;
  background: #f1f5f9;
  color: #334155;
  font-weight: 900;
}

.sheet-drawer .pill:hover{
  background: #e2e8f0;
  border-color: transparent;
}

.sheet-drawer .pill.active{
  background: linear-gradient(135deg,#2563eb,#1d4ed8);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

.sheet-drawer-actions{
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

/* Event log table action buttons */
.event-log td .pill {
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  padding: 4px 10px;
  transition: all 0.2s;
}

.event-log td .pill:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.event-log td .pill:last-child {
  background: transparent;
  color: #ef4444;
  border-color: #fca5a5;
}

.event-log td .pill:last-child:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* Event log kind badges */
.badge-kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-timeout {
  background: #fee2e2;
  color: #ef4444;
  border: 1px solid #fca5a5;
}
.badge-foul {
  background: #fef3c7;
  color: #d97706;
  border: 1px solid #fcd34d;
}
.badge-participation {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}
.badge-score {
  background: #d1fae5;
  color: #059669;
  border: 1px solid #6ee7b7;
}
.badge-own-goal {
  background: #e0f2fe;
  color: #0284c7;
  border: 1px solid #7dd3fc;
}

/* =====================================================
   Screen Panel & Console Header (v2 — Court Visual)
   ===================================================== */

/* Legacy classes kept for sheet-view compatibility */
.shared-game-header{
  width: min(1440px, calc(100vw - 16px));
  margin: var(--toolbar-offset) auto 0;
  background: #dceedd;
  border-radius: 16px;
  box-shadow: 0 10px 30px -5px rgba(2, 6, 23, 0.12), 0 0 0 1px rgba(2, 6, 23, 0.06);
  padding: 16px;
  color: var(--text-primary);
  box-sizing: border-box;
}

.shared-game-header--input{
  border-radius: 16px 16px 0 0;
}

.shared-game-header .console-header{
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.screen-panel{
  width: min(1440px, calc(100vw - 16px));
  margin: 0 auto 20px;
  background: #dceedd;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 10px 30px -5px rgba(2, 6, 23, 0.12), 0 0 0 1px rgba(2, 6, 23, 0.06);
  padding: 16px;
  color: var(--text-primary);
  box-sizing: border-box;
}

/* ---- Header v2 ---- */
.console-header{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.header-row-top{
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

.live-clock{
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  font-family: 'Inter', ui-monospace, monospace;
  letter-spacing: 0.06em;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 8px 18px;
  border-radius: 12px;
  color: #0f172a;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.live-clock::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  background-color: #10b981;
  border-radius: 9999px;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.game-progress-strip{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  min-width: 0;
  flex: 1;
}

.progress-period-nav{
  width: 28px;
  height: 28px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 9999px;
  background: linear-gradient(135deg, #ffffff, #eff6ff);
  color: #1e40af;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15), inset 0 1px 0 rgba(255,255,255,0.85);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex: 0 0 auto;
}

.progress-period-nav svg{
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.progress-period-nav:hover:not(:disabled){
  border-color: #3b82f6;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.22), inset 0 1px 0 rgba(255,255,255,0.9);
  transform: translateY(-1px);
}

.progress-period-nav:active:not(:disabled){
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.18), inset 0 1px 2px rgba(37, 99, 235, 0.12);
}

.progress-period-nav:disabled{
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.game-progress-item{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  background: #ffffff;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-progress-item:hover{
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.game-progress-item.active{
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.08);
}

.game-progress-item input[type="checkbox"]{
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 4px;
  outline: none;
  background-color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin: 0;
}

.game-progress-item input[type="checkbox"]:checked{
  background-color: #3b82f6;
  border-color: #3b82f6;
}

.game-progress-item input[type="checkbox"]:checked::after{
  content: '✓';
  font-size: 10px;
  color: #ffffff;
  font-weight: bold;
}

.game-progress-item input[type="text"]{
  width: 52px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
  font-weight: 700;
  color: inherit;
  text-align: center;
  outline: none;
  transition: all 0.2s;
}

.game-progress-item.active input[type="text"] {
  border-color: rgba(59, 130, 246, 0.2);
  background: #ffffff;
}

.game-progress-item input[type="text"]:focus {
  border-color: #3b82f6 !important;
  background: #ffffff !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.header-actions{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.end-btn{
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  border: none;
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
  transition: all 0.2s;
}

.end-btn:hover{
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.35);
  transform: translateY(-1px);
}

.close-btn{
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text-secondary);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.close-btn:hover{
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* ---- Score Bar ---- */
.score-bar{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.score-team-col{
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-team-col--home{
  flex-direction: row-reverse;
}

.score-team-col--away{
  flex-direction: row;
}

.score-box{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 6px 14px;
  font-weight: 800;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s;
}

.score-box b{
  font-family: 'Inter', ui-monospace, monospace;
  font-size: 28px;
  line-height: 1;
  color: #ffffff;
  font-weight: 900;
}

.score-box.home-score {
  border-left: 4px solid #3b82f6;
}

.score-box.away-score {
  border-left: 4px solid #64748b;
}

/* ---- Timeout badge ---- */
.timeout-badge {
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #64748b;
  transition: all 0.2s;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.timeout-badge.acquired {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}

.timeout-badge.acquired:hover {
  background: #fecaca;
}

/* ---- Control buttons ---- */
.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #475569;
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s;
  height: 32px;
  outline: none;
}

.ctrl-btn:hover {
  background: #334155;
  transform: translateY(-1px);
}

.ctrl-btn:active {
  transform: translateY(0);
}

.ctrl-btn--danger {
  background: #dc2626;
  border-color: #dc2626;
}

.ctrl-btn--danger:hover {
  background: #b91c1c;
}

.ctrl-btn--danger.is-active {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #dc2626;
}

.timeout-btn{
  min-width: 82px;
  border-radius: 10px;
  padding-inline: 10px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.ctrl-btn--teal {
  background: #0f766e;
  border-color: #0f766e;
}

.ctrl-btn--teal:hover {
  background: #0d9488;
}

/* ---- Main Court Area (3-column on PC) ---- */
.main-court-area{
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 12px;
  align-items: start;
}

/* ---- Court Visual ---- */
.court-visual{
  position: relative;
  border-radius: 12px;
  overflow: hidden;
}

.court-svg-wrapper{
  position: relative;
  width: 100%;
  padding-bottom: 66.67%; /* 3:2 aspect ratio */
  background: #e8a735;
  border-radius: 12px;
  overflow: hidden;
}

.court-svg-wrapper svg.court-bg{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Player positions on court — absolute within wrapper */
.court-players-layer{
  position: absolute;
  inset: 0;
  display: flex;
}

.court-half{
  flex: 1;
  position: relative;
  min-height: 0;
}

.court-half.home-half{
  /* drop target for home on-court */
}

.court-half.away-half{
  /* drop target for away on-court */
}

/* Player markers — free position within half court (% + translate center) */
.court-player-marker{
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.court-player-marker.is-dragging-source{
  opacity: 0.12;
  pointer-events: none;
}

.court-drag-ghost{
  position: fixed;
  z-index: 10060;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.court-drag-ghost .basketball-icon{
  cursor: grabbing;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
}

.court-drag-ghost.is-over-bench .basketball-icon{
  transform: scale(1.12);
  box-shadow: 0 0 0 3px #dc2626, 0 8px 24px rgba(220,38,38,0.35);
}

.court-player-marker:active{
  z-index: 5;
}

/* Basketball icon (player marker on court) */
.basketball-icon{
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: #ffffff;
  cursor: grab;
  user-select: none;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.basketball-icon svg{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.basketball-icon span{
  position: relative;
  z-index: 1;
}

.basketball-icon:hover{
  transform: scale(1.12);
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.basketball-icon:active{
  cursor: grabbing;
  transform: scale(1.05);
}

.basketball-icon.empty-icon{
  opacity: 0.25;
  cursor: default;
}

.basketball-icon.empty-icon:hover{
  transform: none;
  box-shadow: none;
}

/* Own-goal buttons on court */
.court-own-btn{
  position: absolute;
  z-index: 2;
  bottom: 10%;
}

.court-own-btn.own-home{
  left: 3%;
}

.court-own-btn.own-away{
  right: 3%;
}

.court-own-btn .ctrl-btn--teal{
  font-size: 10px;
  padding: 4px 8px;
  height: 28px;
}

/* Center guide on court */
.court-center-btn{
  position: absolute;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.court-help-card{
  min-width: 190px;
  padding: 8px 12px;
  border: 2px solid rgba(15,23,42,0.18);
  border-radius: 14px;
  background: rgba(255,255,255,0.96);
  color: var(--text-primary);
  box-shadow: 0 8px 20px rgba(15,23,42,0.22);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
  text-align: left;
  white-space: nowrap;
}

.court-help-card b{
  display: inline-block;
  margin-right: 6px;
  color: #b45309;
  font-weight: 950;
}

/* ---- Bench Area (below court) ---- */
.bench-area{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.bench-zone{
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.bench-zone.is-drop-target{
  background: #fef2f2;
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220,38,38,0.3), inset 0 0 16px rgba(220,38,38,0.06);
}

.bench-header{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.bench-header .ctrl-btn{
  height: auto;
  min-height: 32px;
  padding: 6px 10px;
  white-space: nowrap;
}

.bench-label{
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary);
}

.bench-drag-hint{
  display: block;
  margin: 0 0 6px;
  padding: 0;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  color: #dc2626;
  animation: bench-drag-hint-pulse-slow 4s ease-in-out infinite;
}

@keyframes bench-drag-hint-pulse-slow{
  0%, 100%{
    opacity: 0.35;
    color: #f87171;
  }
  50%{
    opacity: 1;
    color: #dc2626;
  }
}

.bench-players{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
}

.bench-chip{
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: all 0.15s;
  border: 1px solid rgba(0,0,0,0.08);
}

.bench-chip.has-number{
  background: linear-gradient(135deg, #475569, #64748b);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.bench-chip.empty-bench{
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  color: #94a3b8;
  cursor: default;
}

.bench-chip:hover:not(.empty-bench){
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

/* ---- Event Logs (side panels) ---- */
.event-log{
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px;
  background: #ffffff;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
  max-height: 400px;
  overflow-y: auto;
  font-size: 12px;
}

.event-log-title{
  font-weight: 900;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-primary);
}

.event-log table{
  font-size: 11px;
}

.event-log th{
  font-size: 10px;
  padding: 6px 4px;
}

.event-log td{
  padding: 6px 4px;
  font-size: 11px;
}

.event-log td .pill {
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  border-radius: 6px;
  padding: 3px 8px;
  transition: all 0.2s;
}

.event-log td .pill:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.event-log td .pill:last-child {
  background: transparent;
  color: #ef4444;
  border-color: #fca5a5;
}

.event-log td .pill:last-child:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* Legacy classes for console-header .pill compatibility */
.console-header .pill{
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 18px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.console-header .pill:hover{
  border-color: #cbd5e1;
  background: #f8fafc;
  transform: translateY(-1px);
}

.console-header .pill.active{
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

.console-header .pill.active:hover{
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.3);
}

/* ---- Legacy court-grid, team-zone (kept for possible fallback) ---- */
.court-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.team-zone{
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  background: #f8fafc;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.01);
  transition: all 0.3s;
}

.team-zone.home-zone { border-top: 4px solid #3b82f6; }
.team-zone.away-zone { border-top: 4px solid #64748b; }

.zone-title{
  font-size: 15px;
  font-weight: 900;
  margin-bottom: 14px;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.zone-row{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.drop-zone{
  min-height: 100px;
  background: #ffffff;
  border: 2px dashed #e2e8f0;
  border-radius: 12px;
  padding: 10px;
  transition: all 0.2s ease;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
}

.drop-zone.on-court{ background: #f0fdfa; border-color: #99f6e4; }
.drop-zone:hover { border-color: #cbd5e1; }
.drop-zone.on-court:hover { border-color: #5eead4; }

.chip{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-weight: 800;
  font-size: 13px;
  width: 38px;
  height: 38px;
  min-width: 38px;
  margin: 0;
  cursor: grab;
  user-select: none;
  padding: 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.home-zone .chip, .bench-zone--home .chip {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: #ffffff;
}

.away-zone .chip, .bench-zone--away .chip {
  background: linear-gradient(135deg, #374151, #4b5563);
  color: #ffffff;
}

.chip:hover { transform: translateY(-2px); box-shadow: 0 6px 12px -2px rgba(0,0,0,0.15); }
.chip:active { cursor: grabbing; transform: translateY(-1px); }
.chip.empty-chip { background: #f8fafc; border: 2px dashed #cbd5e1; color: #94a3b8; box-shadow: none; cursor: default; }
.chip.empty-chip:hover { transform: none; box-shadow: none; }

/* ---- Responsive: Mobile ---- */
@media (max-width: 960px) {
  .shared-game-header{
    width: 100%;
    padding: 10px;
    border-radius: 0;
  }

  .screen-panel{
    width: 100%;
    padding: 10px;
    margin-top: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* main-court-area を unwrap し、コート・ベンチ・ログを screen-panel 上で並べ替え */
  .main-court-area{
    display: contents;
  }

  .main-court-area .court-visual{
    order: 1;
  }

  .bench-area{
    order: 2;
    margin-top: 0;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .main-court-area .event-log{
    order: 3;
  }

  /* Stack event logs side by side on mobile */
  .mobile-event-logs{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
  }

  .bench-zone{
    padding: 10px;
  }

  .basketball-icon{
    width: 40px;
    height: 40px;
    font-size: 14px;
  }

  .score-box b{
    font-size: 22px;
  }

  .header-row-top{
    flex-wrap: wrap;
  }

  .live-clock{
    font-size: 20px;
    padding: 6px 12px;
    order: 0;
  }

  .header-actions{
    order: 1;
    margin-left: auto;
  }

  .game-progress-strip{
    order: 2;
    width: 100%;
    flex: none;
    justify-content: center;
  }

  .game-progress-item{
    padding: 4px 8px;
    font-size: 10px;
  }

  .event-log{
    max-height: 300px;
  }

  .setup-form-grid{
    grid-template-columns: 1fr 1fr;
  }

  .setup-field-wide{
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .score-bar{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .score-team-col{
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.45);
    padding: 8px 6px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
    width: 100%;
  }
  .score-team-col--home{
    border-left: 3px solid #3b82f6;
  }
  .score-team-col--away{
    border-left: 3px solid #64748b;
  }
  .score-box{
    padding: 4px 10px;
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
  }
  .score-box b{
    font-size: 18px;
  }
  .timeout-btn{
    width: 100%;
    box-sizing: border-box;
  }
  .bench-area{
    grid-template-columns: 1fr 1fr;
  }
  .mobile-event-logs{
    grid-template-columns: 1fr 1fr;
  }

  .setup-modal{
    padding: 16px;
  }

  .sheet-drawer{
    padding: 16px;
  }

  .setup-modal-header{
    align-items: stretch;
    flex-direction: column;
  }

  .sheet-drawer-header{
    align-items: stretch;
    flex-direction: column;
  }

  .setup-close-btn{
    align-self: flex-end;
  }

  .setup-form-grid{
    grid-template-columns: 1fr;
  }

  .setup-field-wide{
    grid-column: auto;
  }

  .sheet-drawer .grid2,
  .sheet-drawer .grid3{
    grid-template-columns: 1fr;
  }
}

/* Event log kind badges */
.badge-kind {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-timeout { background: #fee2e2; color: #ef4444; border: 1px solid #fca5a5; }
.badge-foul { background: #fef3c7; color: #d97706; border: 1px solid #fcd34d; }
.badge-participation { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-score { background: #d1fae5; color: #059669; border: 1px solid #6ee7b7; }
.badge-own-goal { background: #e0f2fe; color: #0284c7; border: 1px solid #7dd3fc; }

/* 印刷専用の背景画像（画面上では非表示） */
.sheet-print-bg{
  display: none;
}

@media print{
  body{ background: #fff; background-image: none; }
  .no-print,
  .editor-pop,
  .sheet-drawer-backdrop,
  .sheet-drawer{
    display: none !important;
  }
  .page{
    display: block !important;
    margin: 0;
    padding: 0;
    min-width: 0;
  }
  .sheet{
    box-shadow: none !important;
    background-image: none !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .sheet-print-bg{
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
  }
  .overlay{
    z-index: 1;
  }
  .edit-overlay,
  .link-overlay{
    display: none !important;
  }
}

/* フルスクリーン切り替えボタン */
.fullscreen-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  background: #1f2937;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
}
.fullscreen-btn:hover {
  background: #374151;
  transform: translateY(-2px);
}
@media print {
  .fullscreen-btn {
    display: none !important;
  }
}

/* ---- Top Scrollbar (Sticky on mobile/tablet) ---- */
.top-scrollbar-container {
  position: sticky;
  top: var(--toolbar-offset);
  left: 0;
  right: 0;
  z-index: 10040; /* app-toolbar(10050)のすぐ下 */
  background: rgba(203, 213, 225, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow-x: auto;
  overflow-y: hidden;
  box-sizing: border-box;
  padding: 0 16px;
  height: 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: none; /* 初期状態は非表示、JSで横スクロールが必要な時だけ表示 */
}

/* スクロールバー自体のデザイン調整（細めにしてスマートにする） */
.top-scrollbar-container::-webkit-scrollbar {
  height: 8px;
}
.top-scrollbar-container::-webkit-scrollbar-track {
  background: transparent;
}
.top-scrollbar-container::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.25);
  border-radius: 9999px;
}
.top-scrollbar-container::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.45);
}

.top-scrollbar-dummy {
  height: 1px;
}
