:root { --game-zoom: 1.25; --commentary-zoom: 1.33; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body { display: flex; height: 100vh; font-family: sans-serif; }
#nav { width: 260px; min-width: 200px; background: #f4f4f4; border-right: 1px solid #ccc;
       display: flex; flex-direction: column; padding: 1rem; }
#nav h2 { font-size: 1rem; margin-bottom: 0.75rem; color: #555; text-transform: uppercase;
           letter-spacing: 0.05em; padding-left: 0.75rem; }
#nav-overview { cursor: pointer; padding: 0.4rem 0.75rem; border-radius: 4px;
                margin-bottom: 0.5rem; transition: background 0.15s; }
#nav-overview:hover { background: #e0e0e0; }
#nav-overview.active { background: #4a90d9; color: #fff; }
#game-list-wrapper { flex: 1; overflow-y: auto; }
#game-list { list-style: none; }
#game-list li { cursor: pointer; padding: 0.5rem 0.75rem; border-radius: 4px;
                margin-bottom: 0.25rem; transition: background 0.15s; }
#game-list li:hover { background: #e0e0e0; }
#game-list li.active { background: #4a90d9; color: #fff; }
#game-list .game-label { font-weight: bold; font-size: 0.9rem; }
#game-list .game-desc { font-size: 0.75rem; color: inherit; opacity: 0.8;
                         margin-top: 0.2rem; }
#zoom-controls { display: flex; align-items: center; justify-content: center;
                 gap: 0.5rem; padding-top: 0.75rem; margin-top: 0.75rem;
                 border-top: 1px solid #ccc; }
#zoom-controls button { width: 2rem; height: 2rem; border: 1px solid #aaa;
                        border-radius: 4px; background: #fff; cursor: pointer;
                        font-size: 1.1rem; line-height: 1; display: flex;
                        align-items: center; justify-content: center; }
#zoom-controls button:hover { background: #e8e8e8; }
#zoom-level { font-size: 0.8rem; color: #555; min-width: 3rem; text-align: center; }
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#controls { display: flex; align-items: center; padding: 0.75rem 1rem;
            border-bottom: 1px solid #ccc; gap: 1rem; }
#controls button { padding: 0.4rem 1rem; border: 1px solid #aaa; border-radius: 4px;
                   background: #fff; cursor: pointer; font-size: 0.95rem; }
#controls button:hover { background: #e8e8e8; }
#title-block { flex: 1; text-align: center; height: 3.8rem; display: flex;
               flex-direction: column; justify-content: center; }
#game-title { font-size: 1.1rem; padding-top: 1rem;}
#game-subtitle { font-size: 0.9rem; color: #666; margin-top: 0.4rem;
                 line-height: 1.3; }
#game-display { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex;
                flex-direction: column; gap: 1.5rem; align-items: center;
                background: #f0f0f0; }
#game-svg-container { display: flex; gap: 1rem; overflow-x: auto;
                      width: 100%; flex-shrink: 0; }
.game-panel { text-align: center; flex-shrink: 0; background: #fff;
              padding: 1rem; border-radius: 6px; }
.game-panel:first-child { margin-left: auto; }
.game-panel:last-child { margin-right: auto; }
.game-panel-header { font-size: 1rem; margin-bottom: 0.25rem; color: #333; }
.game-panel img { zoom: var(--game-zoom); }
#commentary-box { background: #fff; border: 1px solid #ddd; border-radius: 6px;
                  padding: 1rem; text-align: center; display: inline-block; }
#commentary-box:empty { display: none; }
#commentary-box img { height: auto; display: inline-block; zoom: var(--commentary-zoom); }

/* Overview display */
#overview-display { display: none; flex: 1; overflow-y: auto; padding: 2rem; background: #f0f0f0; }
.overview-flow { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 0; }
.overview-card { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 0.75rem 1rem;
                 cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s; position: relative; }
.overview-card:hover { border-color: #4a90d9; box-shadow: 0 2px 8px rgba(74,144,217,0.2); }
/* Vertical connector between game cards */
.overview-card + .overview-card { margin-top: 1rem; }
.overview-card::before { content: ''; position: absolute; top: -1rem; left: 1.5rem;
                         width: 2px; height: 1rem; background: #aaa; }
.overview-card:first-child { margin-top: 0; }
.overview-card:first-child::before { display: none; }
.overview-card-label { font-weight: bold; font-size: 1rem; }
.overview-card-desc { font-size: 0.8rem; color: #666; margin-top: 0.25rem; }

/* Print view (hidden on screen, shown only via @media print) */
#print-view { display: none; }

/* Help button & overlay */
#help-btn { position: fixed; bottom: 20px; right: 20px; width: 2.2rem; height: 2.2rem;
            border-radius: 50%; border: 1px solid #aaa; background: #fff; color: #555;
            font-size: 1.2rem; font-weight: bold; cursor: pointer; z-index: 9000;
            box-shadow: 0 2px 6px rgba(0,0,0,0.15); display: flex;
            align-items: center; justify-content: center; }
#help-btn:hover { background: #e8e8e8; color: #333; }
#help-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
                z-index: 9500; align-items: center; justify-content: center; }
#help-overlay.visible { display: flex; }
#help-content { background: #fff; border-radius: 8px; padding: 1.5rem 2rem; max-width: 380px;
                box-shadow: 0 4px 20px rgba(0,0,0,0.25); font-size: 0.9rem; }
#help-content h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em;
                   color: #555; margin: 0 0 0.5rem; }
#help-content h3:nth-of-type(2) { margin-top: 1rem; }
#help-content table { width: 100%; border-collapse: collapse; }
#help-content td { padding: 0.25rem 0; }
#help-content td:first-child { width: 6rem; white-space: nowrap; }
#help-content kbd { display: inline-block; padding: 0.15rem 0.45rem; background: #f4f4f4;
                    border: 1px solid #ccc; border-radius: 3px; font-family: inherit;
                    font-size: 0.85rem; line-height: 1.3; }
#help-content ul { list-style: disc; padding-left: 1.2rem; }
#help-content li { margin-bottom: 0.3rem; }
#help-content code { background: #f4f4f4; padding: 0.1rem 0.35rem; border-radius: 3px;
                     font-size: 0.85rem; }
#help-branding { margin: 0 0 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid #e0e0e0;
                 font-size: 1rem; color: #333; text-align: center; font-weight: bold; }
#help-branding a { color: #4a90d9; text-decoration: none; }
#help-branding a:hover { text-decoration: underline; }
#help-content > button { margin-top: 1rem; padding: 0.35rem 1.2rem; border: 1px solid #aaa;
                         border-radius: 4px; background: #fff; cursor: pointer;
                         font-size: 0.85rem; display: block; margin-left: auto; }
#help-content > button:hover { background: #e8e8e8; }

/* Sidebar toggle button (visible only on mobile) */
#nav-toggle { display: none; position: fixed; top: 0.5rem; left: 0.5rem; z-index: 8500;
              width: 2.4rem; height: 2.4rem; border: 1px solid #aaa; border-radius: 4px;
              background: #fff; cursor: pointer; font-size: 1.3rem; line-height: 1;
              box-shadow: 0 2px 6px rgba(0,0,0,0.15); align-items: center;
              justify-content: center; }
#nav-toggle:hover { background: #e8e8e8; }

/* Medium-width: narrower sidebar, hide game descriptions */
@media (max-width: 1024px) and (min-width: 769px) {
  #nav { width: 140px; min-width: auto; }
  #nav h2 { padding-left: 0.4rem; font-size: 0.85rem; }
  #nav-overview { padding: 0.3rem 0.4rem; }
  #nav .game-desc { display: none; }
  #game-list li { padding: 0.4rem 0.4rem; }
  #zoom-level { display: none; }
  #zoom-controls { justify-content: space-between; }
}

/* Mobile responsive layout */
@media (max-width: 768px) {
  body { flex-direction: column; }
  #nav-toggle { display: flex; }
  #nav { position: fixed; top: 0; left: 0; bottom: 0; width: 260px; z-index: 8000;
         transform: translateX(-100%); transition: transform 0.25s ease;
         box-shadow: none; }
  #nav.open { transform: translateX(0); box-shadow: 2px 0 12px rgba(0,0,0,0.2); }
  #nav .game-desc { display: none; }
  #nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3);
                  z-index: 7999; }
  #nav-backdrop.visible { display: block; }
  #main { width: 100%; }
  #controls { padding: 0.75rem 0.5rem 0.75rem 3.2rem; }
  #controls button { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
  #game-title { font-size: 1rem; }
  #game-subtitle { font-size: 0.8rem; }
  #game-display { padding: 0.75rem; gap: 1rem; }
  #game-svg-container { flex-wrap: wrap; justify-content: center; }
  .game-panel { max-width: 100%; }
  .game-panel:first-child { margin-left: 0; }
  .game-panel:last-child { margin-right: 0; }
  .game-panel img { max-width: 100%; height: auto; }
  #help-btn { bottom: 12px; right: 12px; }
}

/* Print layout */
@media print {
  body { display: block; height: auto; }
  #nav, #nav-toggle, #nav-backdrop, #controls, #help-btn, #help-overlay,
  #game-display, #overview-display { display: none !important; }
  #main { overflow: visible; }
  #print-view { display: block !important; padding: 0; }
  .print-game { page-break-after: always; padding: 1rem 0; }
  .print-game:last-child { page-break-after: avoid; }
  .print-game-title { font-size: 1.3rem; margin-bottom: 0.25rem; }
  .print-game-desc { font-size: 0.9rem; color: #666; margin-bottom: 1rem; }
  .print-panels { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
  .print-panel { text-align: center; }
  .print-panel-header { font-size: 0.9rem; margin-bottom: 0.25rem; color: #333; }
  .print-panel img { max-width: 100%; height: auto; }
  .print-commentary { margin-top: 1rem; text-align: center; }
  .print-commentary img { max-width: 100%; height: auto; }
}
