@import url('https://fonts.googleapis.com/css2?family=Bungee&display=swap');

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ============================================
   CSS Variables
   ============================================ */
:root {
  color-scheme: light only;

  /* Fonts */
  --font-main: sans-serif;
  --font-display: 'Bungee', sans-serif;

  /* Colors — OKLCH */
  --c-felt: oklch(0.42 0.09 160);
  --c-felt-light: oklch(0.50 0.10 160);
  --c-felt-dark: oklch(0.35 0.07 160);
  --c-navy: oklch(0.22 0.07 260);
  --c-navy-hover: oklch(0.27 0.08 260);
  --c-white: oklch(1 0 0);
  --c-green: oklch(0.65 0.18 155);
  --c-green-light: oklch(0.73 0.18 155);
  --c-red: oklch(0.58 0.20 25);
  --c-red-light: oklch(0.65 0.17 25);
  --c-blue: oklch(0.60 0.15 255);
  --c-blue-light: oklch(0.78 0.12 230);
  --c-gold: oklch(0.75 0.17 75);
  --c-gold-light: oklch(0.85 0.16 90);
  --c-gold-hover: oklch(0.78 0.17 80);
  --c-ivory: oklch(0.99 0.01 100);
  --c-ivory-side: oklch(0.82 0.01 100);
  --c-ivory-dark: oklch(0.72 0.01 100);
  --c-text: oklch(0.30 0 0);
  --c-text-muted: oklch(0.42 0 0);
  --c-text-light: oklch(0.60 0 0);
  --c-surface: oklch(0.97 0 0);
  --c-border: oklch(0.93 0 0);
  --c-border-dark: oklch(0.89 0 0);
  --c-border-light: oklch(0.94 0 0);

  /* Tile dimensions — base values, scaling handled by --board-scale */
  --tile-width: 60px;
  --tile-height: 60px;
  --tile-gap: 0px;
  --tile-radius: 8px;
  --tile-inner-radius: 6px;

  /* Board styling */
  --board-padding: clamp(10px, 2vw, 20px);

  /* Table ambiance */
  --vignette-strength: 0.2;

  /* 3D perspective (sync with GameConfig.CSS) */
  --perspective: 1200px;
  --board-rotation: 10deg;
  --level-height: 10px;

  /* Interaction lifts */
  --hover-lift: 8px;
  --select-lift: 25px;

  /* Z-index layers (sync with GameConfig.Z_INDEX) */
  --z-selected: 999999;
  --z-hover: 999998;
  --z-match-animation: 1000000;
  --z-auto-finish: 5000000;
  --z-overlay: 9000000;
  --z-shuffle-overlay: 9100000;

  /* Animation easing */
  --ease-bounce: cubic-bezier(0.18, 0.89, 0.32, 1.28);
  --ease-smooth: cubic-bezier(0.55, 0, 0.1, 1);

  /* Responsive board scaling */
  --board-scale: 1;
}

/* ============================================
   Base Styles
   ============================================ */
html {
  background-color: var(--c-felt);
  height: 100%;
  overflow: hidden;
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 45%, oklch(0.55 0.12 155 / 0.25) 0%, transparent 70%),
    repeating-linear-gradient(0deg,
      transparent,
      transparent 2px,
      oklch(0 0 0 / 0.03) 2px,
      oklch(0 0 0 / 0.03) 4px),
    repeating-linear-gradient(90deg,
      transparent,
      transparent 2px,
      oklch(0 0 0 / 0.02) 2px,
      oklch(0 0 0 / 0.02) 4px),
    radial-gradient(circle at 30% 70%, var(--c-felt-light) 0%, transparent 50%),
    radial-gradient(circle at 70% 30%, var(--c-felt-light) 0%, transparent 50%);

  &::after {
    content: '';
    position: fixed;
    inset: 0;
    background: url("../assets/logo.svg") center center / 300px auto no-repeat;
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
  }
}

body {
  font-family: var(--font-main);
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;

  /* Vignette overlay */
  &::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 70% 60% at 50% 50%,
        transparent 40%,
        oklch(0 0 0 / var(--vignette-strength)) 100%);
    pointer-events: none;
    z-index: 0;
  }
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
}

.is-gold {
  color: var(--c-gold);
}

.is-red {
  color: var(--c-red);
}

.is-green {
  color: var(--c-green);
}

.is-blue {
  color: var(--c-blue);
}

/* ============================================
   App Layout
   ============================================ */
#app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;

  &>section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding-top: 60px;
  }
}

/* ============================================
   Board Styles
   ============================================ */
.board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  perspective: var(--perspective);
  perspective-origin: 50% 50%;
  padding-bottom: 80px;

  /* Board surface */
  &>div {
    position: relative;
    width: calc(var(--board-base-size, 8) * (var(--tile-width) + var(--tile-gap)));
    height: calc(var(--board-base-size, 8) * (var(--tile-height) + var(--tile-gap)));
    transform: scale(var(--board-scale)) rotateX(var(--board-rotation));
    transform-origin: center center;
    transform-style: preserve-3d;
    transition: transform 0.5s ease-out;

    /* Shuffle overlay */
    &>div {
      position: fixed;
      bottom: 40px;
      left: 50%;
      transform: translateX(-50%);
      background-color: oklch(0.25 0.05 160 / 0.85);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      color: white;
      padding: 0.5rem 1.5rem;
      border-radius: 2rem;
      z-index: var(--z-shuffle-overlay);
      box-shadow: 0 4px 15px oklch(0 0 0 / 0.2);
      font-family: var(--font-display);
    }
  }

  /* Auto-finish button */
  &>button {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-auto-finish);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    background-color: var(--c-gold);
    color: var(--c-navy);
    border: none;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
    font-family: var(--font-display);
    white-space: nowrap;

    & i {
      font-size: 1.1rem;
    }

    &:hover {
      transform: translateX(-50%) translateY(-2px);
      background-color: var(--c-gold-hover);
    }

    &:active {
      transform: translateX(-50%) translateY(0);
    }
  }
}

/* ============================================
   Header Styles
   ============================================ */
.game-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: oklch(0 0 0 / 0.15);

  /* Left side */
  &> :first-child {
    display: flex;
    flex-direction: column;
    gap: 2px;

    & span {
      font-family: var(--font-display);
      color: var(--c-white);
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
  }

  /* Right side (nav) */
  &>nav {
    display: flex;
    gap: 10px;

    & button {
      width: 42px;
      height: 42px;
      border: none;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      font-size: 1.3rem;
      color: var(--c-navy);
      background-color: var(--c-white);
      box-shadow: 0 2px 8px oklch(0 0 0 / 0.1);
      transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;

      &:hover {
        transform: scale(1.05);
        box-shadow: 0 4px 12px oklch(0 0 0 / 0.15);
      }

      &:active {
        transform: scale(0.95);
      }
    }
  }
}

/* ============================================
   Tile Styles
   ============================================ */
.tile {
  position: absolute;
  width: var(--tile-width);
  height: var(--tile-height);
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  cursor: pointer;
  user-select: none;
  overflow: visible;
  touch-action: manipulation;
  border-radius: var(--tile-radius);
  z-index: var(--base-z-index);
  transition: transform 0.25s var(--ease-smooth), z-index 0s 0.25s;
  transform-style: preserve-3d;
  transform: translateZ(calc(var(--level) * var(--level-height)));
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;

  /* Tile face */
  &::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--tile-image);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-color: var(--c-ivory);
    border-radius: var(--tile-inner-radius);
    transform: translateZ(0);
    box-shadow:
      0 1px 0 var(--c-ivory-side),
      0 2px 0 var(--c-ivory-side),
      0 3px 0 var(--c-ivory-side),
      0 4px 0 var(--c-ivory-side),
      0 5px 0 var(--c-ivory-side),
      0 7px 10px oklch(0 0 0 / 0.25);
    filter: brightness(calc(1 - var(--depth-darkness, 0) * 1.2));
    transition: all 0.25s var(--ease-smooth);
    pointer-events: none;
    z-index: 0;
  }

  /* Bevel and reflection */
  &::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--tile-inner-radius);
    transform: translateZ(0.1px);
    background: radial-gradient(circle at 20% 20%, oklch(1 0 0 / 0.4) 0%, transparent 60%);
    box-shadow:
      inset 0 2px 4px oklch(1 0 0 / 0.8),
      inset 0 -2px 4px oklch(0 0 0 / 0.1);
    pointer-events: none;
    transition: all 0.25s var(--ease-smooth);
  }

  /* Front layer (illustration) */
  &>span {
    position: absolute;
    inset: 0;
    background-image: var(--tile-front-image, none);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 5;
    border-radius: var(--tile-inner-radius);
    transform: translateZ(0.1px);
  }

  /* Expanded hit area for playable tiles */
  &>.tile-hitbox {
    position: absolute;
    inset: -12px;
    z-index: -1;
    cursor: pointer;
  }

  /* Uncovered tile - enhanced depth */
  &:not(.covered)::before {
    box-shadow:
      0 1px 0 var(--c-ivory-side),
      0 2px 0 var(--c-ivory-side),
      0 3px 0 var(--c-ivory-side),
      0 4px 0 var(--c-ivory-side),
      0 5px 0 var(--c-ivory-side),
      0 8px 12px oklch(0 0 0 / 0.2);
  }

  /* Covered tile */
  &.covered {
    cursor: not-allowed;
    filter: grayscale(1) brightness(0.8);

    &::before {
      background-color: var(--c-ivory-side);
      box-shadow:
        0 1px 0 var(--c-ivory-dark),
        0 2px 0 var(--c-ivory-dark),
        0 3px 0 var(--c-ivory-dark),
        0 4px 0 var(--c-ivory-dark),
        0 5px 0 var(--c-ivory-dark),
        0 6px 8px oklch(0 0 0 / 0.35);
    }
  }

  /* Selected tile & Matching/mismatching second tile */
  &.selected,
  &.match-success,
  &.match-failure {
    z-index: var(--z-selected);
    transform: translateZ(calc(var(--level) * var(--level-height) + var(--select-lift)));
    transition: transform 0.25s var(--ease-bounce), z-index 0s;

    &::before {
      box-shadow:
        /* Ivory 3D Sides */
        0 1px 0 var(--c-ivory-side),
        0 2px 0 var(--c-ivory-side),
        0 3px 0 var(--c-ivory-side),
        0 4px 0 var(--c-ivory-side),
        0 5px 0 var(--c-ivory-side),
        /* Solid Dark Outer Contour (spread = 4px) */
        0 0 0 4px var(--c-gold),
        0 1px 0 4px var(--c-gold),
        0 2px 0 4px var(--c-gold),
        0 3px 0 4px var(--c-gold),
        0 4px 0 4px var(--c-gold),
        0 5px 0 4px var(--c-gold),
        /* Base diffuse drop shadow */
        0 25px 40px oklch(0 0 0 / 0.3);
      filter: brightness(1.1);
    }

    &::after {
      background: radial-gradient(circle at 20% 20%, oklch(1 0 0 / 0.6) 0%, transparent 60%);
    }
  }

  /* Hover state (uncovered only and not selected/matching) */
  &:not(.covered):not(.selected):not(.match-success):not(.match-failure):hover {
    z-index: var(--z-hover);
    transform: translateZ(calc(var(--level) * var(--level-height) + var(--hover-lift)));
    transition: transform 0.25s var(--ease-bounce), z-index 0s;

    &::before {
      transition: all 0.25s var(--ease-bounce);
      box-shadow:
        0 1px 0 var(--c-ivory-side),
        0 2px 0 var(--c-ivory-side),
        0 3px 0 var(--c-ivory-side),
        0 4px 0 var(--c-ivory-side),
        0 5px 0 var(--c-ivory-side),
        0 14px 22px oklch(0 0 0 / 0.2);
      filter: brightness(1.05);
    }

    &::after {
      transition: all 0.25s var(--ease-bounce);
    }
  }

  /* Active state for touch feedback */
  &:not(.covered):not(.selected):not(.match-success):not(.match-failure):active {
    transform: translateZ(calc(var(--level) * var(--level-height) + var(--hover-lift) - 2px)) scale(0.96);
    transition: transform 0.05s ease-out;
  }

  /* Match success animation */
  &.match-success {
    animation: match-success 0.5s cubic-bezier(0.45, 0.05, 0.55, 0.95) forwards;
    z-index: 1000000;
  }

  /* Match failure animation */
  &.match-failure {
    animation: match-failure 0.4s ease-in-out;
  }

  /* Shake animation for locked tiles */
  &.locked-shake {
    animation: shake 0.3s ease-in-out;
    cursor: not-allowed;
  }

  /* Shuffle animations */
  &.shuffling-out {
    animation: shuffle-out 0.4s ease-in forwards;
  }

  &.shuffling-in {
    animation: shuffle-in 0.4s ease-out forwards;
  }
}

/* Faster animation for auto-finish */
.auto-finishing .tile.match-success {
  animation-duration: 0.15s;
}

/* ============================================
   Keyframes
   ============================================ */
@keyframes match-success {
  0% {
    transform: translateZ(calc(var(--level) * var(--level-height))) scale(1);
    opacity: 1;
  }

  30% {
    transform: translateZ(calc(var(--level) * var(--level-height) + 60px)) scale(1.1);
    opacity: 1;
  }

  100% {
    transform: translateZ(calc(var(--level) * var(--level-height) + 200px)) scale(0.8);
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes match-failure {

  0%,
  100% {
    transform: translateZ(calc(var(--level) * var(--level-height))) translateX(0);
  }

  20%,
  60% {
    transform: translateZ(calc(var(--level) * var(--level-height))) translateX(-10px);
  }

  40%,
  80% {
    transform: translateZ(calc(var(--level) * var(--level-height))) translateX(10px);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateZ(calc(var(--level) * var(--level-height))) rotate(0deg);
  }

  25% {
    transform: translateZ(calc(var(--level) * var(--level-height))) rotate(-3deg);
  }

  75% {
    transform: translateZ(calc(var(--level) * var(--level-height))) rotate(3deg);
  }
}

@keyframes shuffle-out {
  0% {
    transform: translateZ(0) scale(1) rotate(0deg);
    opacity: 1;
  }

  50% {
    transform: translateZ(100px) scale(0.5) rotate(180deg);
    opacity: 0.5;
  }

  100% {
    transform: translateZ(200px) scale(0) rotate(360deg);
    opacity: 0;
  }
}

@keyframes shuffle-in {
  0% {
    transform: translateZ(200px) scale(0) rotate(-360deg);
    opacity: 0;
  }

  50% {
    transform: translateZ(100px) scale(0.5) rotate(-180deg);
    opacity: 0.5;
  }

  100% {
    transform: translateZ(0) scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes modal-in {
  0% {
    opacity: 0;
    transform: scale(0.85) translateY(30px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ============================================
   Tile Leave Transition
   ============================================ */
.tile-leave-active {
  transition: all 0.4s cubic-bezier(0.55, 0, 0.1, 1);
}

.tile-leave-to {
  opacity: 0;
  transform: scale(0.5) translateY(-20px);
}

/* ============================================
   Game Overlays
   ============================================ */
.game-overlay {
  position: fixed;
  inset: 0;
  background-color: oklch(0 0 0 / 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--z-overlay);
}

/* ============================================
   Modal Styles
   ============================================ */
.game-modal {
  position: relative;
  width: 90%;
  max-width: 420px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px oklch(0 0 0 / 0.4);
  animation: modal-in 0.35s var(--ease-bounce) both;

  /* Modal top (first child) */
  &> :first-child {
    padding: 2.5rem 2rem 2rem;

    & h1 {
      font-family: var(--font-display);
      font-size: 2.2rem;
      font-weight: 900;
      color: var(--c-navy);
      letter-spacing: 1px;
    }

    /* Close button */
    &>button {
      position: absolute;
      top: 15px;
      right: 15px;
      background: oklch(0 0 0 / 0.1);
      border: none;
      width: 32px;
      height: 32px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      color: var(--c-text);
      z-index: 10;
      transition: background 0.2s;

      &:hover {
        background: oklch(0 0 0 / 0.2);
      }
    }

    /* Color variants */
    &.green-top {
      background: linear-gradient(135deg, var(--c-green), var(--c-green-light));
    }

    &.red-top {
      background: linear-gradient(135deg, var(--c-red), var(--c-red-light));
    }

    &.blue-top {
      background: linear-gradient(135deg, var(--c-blue), var(--c-blue-light));
    }

    &.gold-top {
      background: linear-gradient(135deg, var(--c-gold), var(--c-gold-light));
    }
  }

  /* Modal bottom (last child) */
  &> :last-child {
    background: var(--c-white);
    padding: 1.5rem 2rem 2rem;
    text-align: center;

    &>p {
      font-size: 1.05rem;
      color: var(--c-text-muted);
      margin-bottom: 1.5rem;
      font-weight: 500;
    }

    /* Primary action button */
    &>button:first-of-type {
      display: block;
      width: 100%;
      padding: 12px 20px;
      background-color: var(--c-navy);
      color: var(--c-white);
      border: none;
      border-radius: 10px;
      font-family: var(--font-display);
      font-size: 1rem;
      font-weight: 800;
      letter-spacing: 1px;
      cursor: pointer;
      transition: transform 0.15s ease, background-color 0.15s ease;

      &:hover {
        background-color: var(--c-navy-hover);
        transform: translateY(-2px);
      }

      &:active {
        transform: translateY(0);
      }
    }

    /* Input fields */
    & input {
      width: 100%;
      padding: 12px 16px;
      border: 2px solid var(--c-border-dark);
      border-radius: 8px;
      font-size: 1rem;
      font-family: var(--font-main);
      margin-bottom: 8px;
      outline: none;
      transition: border-color 0.2s;

      &:focus {
        border-color: var(--c-navy);
      }
    }
  }

  /* Error text */
  & .error-text {
    color: var(--c-red);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    margin-top: -4px;
  }

  /* Text button (secondary) */
  & .modal-text-btn {
    background: none;
    border: none;
    color: var(--c-text-light);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 1rem;
    font-family: var(--font-main);

    &:hover {
      color: var(--c-text-muted);
    }
  }
}

/* ============================================
   Settings Modal (Tile Sets)
   ============================================ */
.settings-modal> :last-child>div {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;

  & .tile-set-item {
    background: var(--c-surface);
    border: 2px solid var(--c-border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px oklch(0 0 0 / 0.08);
      border-color: oklch(0.86 0.01 240);
    }

    &.active {
      border-color: var(--c-green);
      background-color: oklch(0.98 0.02 155);
    }

    /* Tile set info (first child) */
    &> :first-child {
      flex: 1;
      text-align: left;

      & h3 {
        font-size: 0.9rem;
        font-weight: 700;
        color: var(--c-navy);
        margin-bottom: 2px;
        font-family: var(--font-display);
      }

      & p:first-of-type {
        margin-bottom: 4px;
        font-size: 0.75rem;
        color: oklch(0.53 0.01 250);

        & a {
          color: var(--c-blue);
          text-decoration: none;

          &:hover {
            text-decoration: underline;
          }
        }
      }

      & p:last-of-type {
        font-size: 0.8rem;
        color: oklch(0.40 0.01 250);
        line-height: 1.3;
        font-style: italic;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-bottom: 0;
      }
    }

    /* Status icon (second child) */
    &>div+div {
      font-size: 1.4rem;
    }
  }
}

/* ============================================
   Leaderboard Modal
   ============================================ */
.leaderboard-modal {
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;

  &> :last-child {
    padding: 0;
    overflow: hidden;

    &>div {
      overflow-y: auto;
      flex: 1;
      max-height: 50vh;
      padding: 0;
      scrollbar-width: thin;
      scrollbar-color: oklch(0 0 0 / 0.15) transparent;

      &::-webkit-scrollbar {
        width: 6px;
      }

      &::-webkit-scrollbar-track {
        background: transparent;
      }

      &::-webkit-scrollbar-thumb {
        background-color: oklch(0 0 0 / 0.15);
        border-radius: 3px;

        &:hover {
          background-color: oklch(0 0 0 / 0.25);
        }
      }

      /* Loading state */
      &>div {
        padding: 2rem;
        color: var(--c-text-light);
        font-style: italic;
        text-align: center;
      }

      /* Leaderboard list */
      & ul {
        list-style: none;
        margin: 0;
        padding: 0;
        text-align: left;

        & li {
          display: flex;
          justify-content: space-between;
          align-items: center;
          padding: 12px 20px;
          border-bottom: 1px solid var(--c-border-light);
          font-size: 1rem;
          color: var(--c-text);

          &:last-child {
            border-bottom: none;
          }

          &.current-user {
            background-color: oklch(0.95 0.03 255);
            font-weight: bold;
            color: var(--c-navy);

            & span:first-child {
              color: var(--c-navy);
            }
          }

          /* Rank */
          & span:first-child {
            font-weight: 800;
            width: 40px;
            color: var(--c-text-light);
          }

          /* Name */
          & span:nth-child(2) {
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            padding-right: 10px;
          }

          /* Level */
          & span:last-child {
            font-weight: 600;
            color: var(--c-green);
          }
        }
      }
    }
  }
}

/* ============================================
   Profile Modal
   ============================================ */
.profile-modal {

  /* Profile name container in header-extra */
  &> :first-child>div {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 5px;

    & h2 {
      font-size: 1.8rem;
      color: var(--c-navy);
      margin-bottom: 0.2rem;
      font-weight: 800;
    }

    & button {
      background: none;
      border: none;
      cursor: pointer;
      color: var(--c-white);
      font-size: 1.4rem;
      padding: 5px;
      border-radius: 50%;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      justify-content: center;
      position: static;
      width: auto;
      height: auto;

      &:hover {
        background-color: oklch(0.60 0.15 255 / 0.1);
        transform: scale(1.1);
      }
    }
  }

  /* Profile level */
  &> :last-child>p:first-child {
    font-size: 1.1rem;
    color: var(--c-green);
    font-weight: 600;
  }

  /* Separator */
  &> :last-child>hr {
    border: none;
    height: 1px;
    background-color: var(--c-border-light);
    margin: 1.5rem 0;
    width: 100%;
  }

  /* User code section */
  &> :last-child>div {
    text-align: center;

    &>h3 {
      font-size: 1.1rem;
      color: var(--c-navy);
      margin-bottom: 0.5rem;
    }

    &>p:first-child {
      font-size: 0.9rem;
      color: oklch(0.48 0 0);
      margin-bottom: 1rem;
      line-height: 1.4;
    }

    /* User code display */
    &>div {
      padding: 0.8rem;
      background: var(--c-surface);
      border-radius: 8px;
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 12px;
      border: 1px dashed oklch(0.83 0 0);
      margin-bottom: 0.5rem;

      & strong {
        color: var(--c-navy);
        font-family: monospace;
        font-size: 1.2rem;
        letter-spacing: 2px;
      }

      & button {
        background: none;
        border: none;
        color: var(--c-blue);
        cursor: pointer;
        font-size: 1.2rem;
        padding: 4px;
        transition: transform 0.1s;

        &:active {
          transform: scale(0.9);
        }
      }
    }
  }
}

/* ============================================
   Toast Notification
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background-color: oklch(0.25 0.05 160 / 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: white;
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 12px 40px oklch(0 0 0 / 0.3);
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 10000000;
  font-family: var(--font-main);
  font-size: 1rem;
  pointer-events: none;
  transition: all 0.4s var(--ease-bounce);

  & i {
    font-size: 1.5rem;
    color: var(--c-green-light);
  }
}

/* ============================================
   Vue Transitions
   ============================================ */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.toast-fade-enter-active,
.toast-fade-leave-active {
  transition: all 0.4s var(--ease-bounce);
}

.toast-fade-enter-from,
.toast-fade-leave-to {
  opacity: 0;
  transform: translate(-50%, 30px) scale(0.9);
}

/* ============================================
   Responsive Styles
   ============================================ */

/* Tablet - 768px */
@media (max-width: 768px) {
  :root {
    --tile-width: 50px;
    --tile-height: 50px;
    --level-height: 9px;
    --hover-lift: 7px;
    --select-lift: 22px;
    --tile-radius: 7px;
    --tile-inner-radius: 5px;
  }

  .game-header {
    padding: 10px 16px;
  }
}

/* Mobile - 600px */
@media (max-width: 600px) {
  :root {
    --tile-width: 42px;
    --tile-height: 42px;
    --level-height: 7px;
    --hover-lift: 5px;
    --select-lift: 17px;
    --board-rotation: 15deg;
    --tile-radius: 6px;
    --tile-inner-radius: 4px;
  }

  #app>section {
    padding-top: 50px;
  }

  .game-modal {
    width: 92%;

    &> :first-child h1 {
      font-size: 1.8rem;
    }

    &> :last-child>p {
      font-size: 0.95rem;
    }
  }

  .tile::before {
    box-shadow:
      0 1px 0 var(--c-ivory-side),
      0 2px 0 var(--c-ivory-side),
      0 3px 0 var(--c-ivory-side),
      0 4px 0 var(--c-ivory-side),
      0 6px 8px oklch(0 0 0 / 0.25);
  }
}

/* Small Mobile - 480px */
@media (max-width: 480px) {
  :root {
    --tile-width: 38px;
    --tile-height: 38px;
    --level-height: 6px;
    --hover-lift: 4px;
    --select-lift: 12px;
    --perspective: 800px;
    --tile-radius: 5px;
    --tile-inner-radius: 4px;
  }

  .board>div>div {
    font-size: 0.9rem;
    padding: 0.4rem 1rem;
  }

  .tile::before {
    box-shadow:
      0 1px 0 var(--c-ivory-side),
      0 2px 0 var(--c-ivory-side),
      0 3px 0 var(--c-ivory-side),
      0 5px 6px oklch(0 0 0 / 0.25);
  }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 600px) {
  .game-header {
    padding: 6px 16px;
  }

  #app>section {
    padding-top: 44px;
  }

  .board {
    padding-bottom: 50px;

    &>button {
      bottom: 10px;
      height: 32px;
      font-size: 0.8rem;
    }
  }
}

/* Very small landscape */
@media (orientation: landscape) and (max-height: 450px) {
  .game-header {
    padding: 4px 12px;
  }

  #app>section {
    padding-top: 36px;
  }

  .board>button {
    bottom: 6px;
    height: 28px;
    font-size: 0.75rem;
  }
}

/* Reduce animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {

  .tile,
  .tile::before,
  .tile::after {
    transition: none;
  }

  .tile.match-success,
  .tile.match-failure,
  .tile.shuffling-out,
  .tile.shuffling-in {
    animation: none;
  }
}

/* ============================================
   Menu Hub Modal
   ============================================ */
.menu-modal {

  /* Override default modal padding for the content area */
  &> :last-child {
    padding: 0 !important;
  }

  & .menu-hub-buttons {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;

    & button,
    & a {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 16px;
      width: 100%;
      padding: 20px 24px;
      background-color: transparent;
      border: none;
      border-bottom: 1px solid var(--c-border-light);
      border-radius: 0;
      font-family: var(--font-main);
      font-size: 1.1rem;
      font-weight: 500;
      color: var(--c-navy);
      cursor: pointer;
      text-decoration: none;
      transition: background-color 0.2s ease;
      box-shadow: none;
      text-align: left;
      margin: 0;
      box-sizing: border-box;

      &:last-child {
        border-bottom: none;
      }

      & i {
        font-size: 1.5rem;
        min-width: 32px;
        text-align: center;
        transition: transform 0.2s ease;
      }

      &:hover {
        background-color: oklch(0 0 0 / 0.03);

        & i {
          transform: scale(1.1);
        }
      }

      &:active {
        background-color: oklch(0 0 0 / 0.06);
      }
    }
  }
}