:root{
    --bg: #f6f6f4;
    --bg-2: #ffffff;
    --panel: #f0f0f2;
    --card-bg: #121214;
    --text: #16161a;
    --muted: #7a7a84;
    --line: #e5e5e9;

    --c-cyan: #4cc9f0;
    --c-magenta: #f72585;
    --c-amber: #ffb703;
    --c-green: #06d6a0;
    --c-purple: #b388ff;
    --c-orange: #ff8500;
  }

  *{ box-sizing:border-box; }
  html,body{ margin:0; padding:0; }

  body{
    background: var(--bg);
    color:var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    min-height:100vh;
    display:flex;
    flex-direction:column;
    align-items:center;
    padding: 40px 20px 64px;
  }

  /* ---------- Header minimal ---------- */
  header{
    text-align:center;
    margin-bottom: 32px;
  }
  .title-main{
    font-size: clamp(24px, 4vw, 32px);
    font-weight:800;
    letter-spacing:-0.4px;
    margin:0;
    color: var(--text);
  }
  .subtitle{
    color:var(--muted);
    font-size: 14px;
    margin-top:6px;
  }

  /* ---------- Grid of game cards ---------- */
  #grid{
    display:grid;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 18px;
    width: 100%;
    max-width: 220px;
  }

  .game-card{
    position:relative;
    border-radius: 14px;
    border: none;
    cursor:pointer;
    padding: 0;
    background: var(--card-bg);
    font-family:inherit;
    display:flex;
    flex-direction:column;
    text-align:left;
    overflow:hidden;
    box-shadow: 0 6px 16px -10px rgba(0,0,0,0.35);
    transition: transform .15s ease, box-shadow .2s ease;
  }
  .game-card:hover{
    transform: translateY(-3px);
    box-shadow: 0 14px 24px -12px rgba(0,0,0,0.4);
  }
  .game-card:active{ transform: translateY(0) scale(.98); }

  .game-card .preview{
    aspect-ratio: 4 / 3;
    display:flex;
    align-items:center;
    justify-content:center;
  }
  .game-card .preview .icon{
    font-size: 30px;
  }
  .game-card .info{
    padding: 10px 12px 12px;
    display:flex;
    flex-direction:column;
    gap: 4px;
  }
  .game-card .title{
    font-size: 13px;
    font-weight:700;
    color: #fff;
    letter-spacing: 0.1px;
  }
  .game-card .desc{
    font-size: 11px;
    color: #a5a5ad;
    line-height: 1.35;
  }

  /* ---------- Game screen ---------- */
  #screen{
    display:none;
    width:100%;
    max-width: 480px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 20px 40px -24px rgba(0,0,0,.25);
  }
  #screen.active{ display:block; }
  #grid.hidden{ display:none; }
  header.hidden{ display:none; }

  #screen-top{
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
  }
  #screen-title{
    font-size:15px;
    letter-spacing:0.2px;
    font-weight:800;
    color: var(--text);
  }
  #back-btn{
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 12px;
    cursor:pointer;
  }
  #back-btn:hover{ border-color: var(--text); }

  #game-container{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 14px;
  }

  .status-line{
    font-size: 13px;
    color: var(--muted);
    letter-spacing: 1px;
    min-height: 18px;
    text-align:center;
  }

  .btn{
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
  }
  .btn:hover{ border-color: var(--c-cyan); color: var(--c-cyan); }

  /* Guess The Flag */
  .flag-display{
    font-size: 90px;
    line-height: 1;
    margin: 6px 0 4px;
  }
  .flag-progress{
    font-size: 12px;
    color: var(--muted);
  }
  #flag-options{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
  }
  .flag-option{
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor:pointer;
    transition: border-color .15s ease, background .15s ease;
  }
  .flag-option:hover{ border-color: var(--c-cyan); }
  .flag-option.correct{ background: #e6f9f2; border-color: var(--c-green); color:#0a7a5c; }
  .flag-option.wrong{ background: #fdeaf0; border-color: var(--c-magenta); color:#c21e5a; }
  .flag-option:disabled{ cursor:default; }

  #flag-feedback{
    font-size: 13px;
    font-weight: 700;
    min-height: 18px;
    text-align:center;
  }
  #flag-score{
    font-size: 12px;
    color: var(--muted);
  }

  footer{
    margin-top: 40px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 1px;
    text-align:center;
  }
