:root {
  --bg: #f7f1e5;
  --panel: rgba(255, 255, 255, 0.86);
  --text: #2f2b28;
  --soft: #655e57;
  --line: rgba(83, 70, 60, 0.14);
  --coral: #ef8a64;
  --sun: #efbd6c;
  --sea: #69b6b0;
  --leaf: #8ebf78;
  --shadow: 0 20px 60px rgba(59, 45, 34, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Zen Kaku Gothic New", sans-serif;
  background:
    linear-gradient(135deg, rgba(239, 138, 100, 0.18), transparent 32%),
    linear-gradient(225deg, rgba(105, 182, 176, 0.2), transparent 30%),
    var(--bg);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.game-app {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.flash-pop {
  position: fixed;
  left: 50%;
  top: 18px;
  z-index: 100;
  width: min(520px, calc(100% - 28px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(180, 35, 24, 0.22);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.98);
  box-shadow: var(--shadow);
}

.flash-pop p {
  margin: 0;
  line-height: 1.6;
}

.flash-pop button {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.home-link,
.game-tabs a,
.logout-form button,
.auth-card button,
.primary-action {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  text-decoration: none;
}

.home-link,
.game-tabs a {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.62);
  font-weight: 700;
}

.game-kicker {
  margin: 0;
  color: var(--soft);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0.35rem 0 0;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logout-form button,
.auth-card button,
.primary-action {
  padding: 0 18px;
  background: var(--text);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.game-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0;
}

.game-tabs a.is-active {
  background: var(--coral);
  color: #fff;
}

.game-tabs span {
  margin-left: 6px;
  color: inherit;
  font-size: 0.78rem;
  opacity: 0.75;
}

.next-game-pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-left: 0;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px dashed rgba(47, 43, 40, 0.2);
  background: rgba(255, 255, 255, 0.42);
  color: var(--soft);
  font-size: 0.9rem;
  font-weight: 700;
  opacity: 1;
}

.game-showcase {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.08fr);
  gap: 18px;
  margin-bottom: 24px;
}

.game-spotlight {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.52);
  box-shadow: var(--shadow);
}

.game-spotlight-media img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.74);
}

.game-spotlight-copy {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.game-spotlight-tagline,
.game-spotlight-hook,
.game-library-header p,
.game-library-copy p {
  margin: 0;
  color: var(--soft);
  line-height: 1.7;
}

.game-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game-chip-row span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(47, 43, 40, 0.1);
  color: var(--soft);
  font-size: 0.88rem;
  font-weight: 700;
}

.game-spotlight-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.game-spotlight-meta div {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(47, 43, 40, 0.1);
}

.game-spotlight-meta dt {
  color: var(--soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.game-spotlight-meta dd {
  margin: 0.35rem 0 0;
  font-weight: 800;
  line-height: 1.45;
}

.game-library {
  display: grid;
  align-content: start;
  gap: 12px;
}

.game-library-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

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

.game-library-card {
  display: grid;
  gap: 10px;
  overflow: hidden;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.52);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.game-library-card.is-active {
  border-color: rgba(239, 138, 100, 0.5);
  box-shadow: 0 16px 36px rgba(239, 138, 100, 0.16);
}

.game-library-card.is-locked {
  opacity: 0.84;
}

.game-library-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.74);
}

.game-library-copy {
  display: grid;
  gap: 6px;
}

.game-library-topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.game-library-topline strong {
  line-height: 1.35;
}

.game-library-topline span {
  color: var(--soft);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.auth-panel,
.play-panel,
.rank-card,
.creator-call {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: clamp(22px, 4vw, 36px);
}

.creator-call {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: clamp(18px, 3vw, 28px);
  margin-bottom: 24px;
}

.creator-call p {
  margin: 0.75rem 0 0;
  color: var(--soft);
  line-height: 1.8;
}

.creator-call-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.auth-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
}

label {
  display: grid;
  gap: 6px;
  color: var(--soft);
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 12px;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
}

.play-panel {
  padding: clamp(18px, 3vw, 28px);
}

.play-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.play-heading p {
  color: var(--soft);
}

.score-box {
  min-width: 120px;
  padding: 12px;
  text-align: right;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.score-box span {
  display: block;
  color: var(--soft);
}

.score-box strong {
  font-size: 2.2rem;
}

.game-stage {
  position: relative;
  width: 100%;
  height: min(62vh, 520px);
  min-height: 360px;
  margin-top: 18px;
  overflow: hidden;
  border: 2px solid rgba(47, 43, 40, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0.28)),
    repeating-linear-gradient(90deg, rgba(105,182,176,0.12) 0 24px, transparent 24px 48px);
  touch-action: manipulation;
}

.game-stage.is-othello {
  height: auto;
  min-height: 0;
  overflow: visible;
}

.game-stage.is-sudoku {
  height: auto;
  min-height: 0;
  overflow: visible;
  border-color: rgba(34, 45, 58, 0.16);
  background: #fbfdff;
}

.game-stage.is-giggers {
  height: min(66vh, 560px);
  min-height: 420px;
  overflow: hidden;
}

.game-stage.is-snake {
  height: auto;
  min-height: 0;
  overflow: visible;
  padding: 10px;
  background: #f7fbfb;
}

.othello-shell {
  display: grid;
  justify-items: center;
  gap: 14px;
  height: auto;
  padding: clamp(10px, 2vw, 16px);
}

.othello-toolbar {
  width: min(100%, 520px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.othello-difficulty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--soft);
  font-weight: 700;
}

.othello-difficulty select {
  min-height: 40px;
  border: 1px solid rgba(47, 43, 40, 0.14);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.othello-scoreline {
  margin: 0;
  color: var(--soft);
  font-weight: 700;
  white-space: nowrap;
}

.othello-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: min(100%, 520px);
  max-width: 100%;
  aspect-ratio: 1;
  border: 4px solid #2f6f4f;
  border-radius: 8px;
  overflow: hidden;
  background: #2f9b67;
}

.othello-cell {
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(47, 43, 40, 0.28);
  background: transparent;
  cursor: pointer;
  transition: background-color 0.18s ease;
}

.othello-cell.is-legal {
  background: rgba(239, 189, 108, 0.3);
}

.othello-cell.is-filled {
  background: rgba(0, 0, 0, 0.02);
}

.disc {
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.18), 0 4px 10px rgba(0, 0, 0, 0.18);
  transition: transform 0.16s ease, opacity 0.16s ease, background-color 0.16s ease;
}

.disc.black {
  background: #202020;
}

.disc.white {
  background: #f7f2e7;
}

.disc.is-hidden {
  opacity: 0;
  transform: scale(0.72);
  box-shadow: none;
  pointer-events: none;
}

.sudoku-shell {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 16px;
  background: #fbfdff;
}

.sudoku-topbar {
  width: min(100%, 560px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #27313a;
}

.sudoku-difficulty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #394958;
  font-weight: 700;
}

.sudoku-difficulty select {
  min-height: 40px;
  border: 2px solid #27313a;
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: #1f2933;
  font: inherit;
  font-weight: 700;
}

.sudoku-note {
  margin: 0;
  color: #526273;
  font-weight: 700;
  text-align: right;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  width: min(100%, 560px);
  max-width: 100%;
  aspect-ratio: 1;
  border: 3px solid #27313a;
  background: #ffffff;
  gap: 0;
  box-shadow: 0 14px 32px rgba(39, 49, 58, 0.12);
}

.sudoku-cell {
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-right: 1px solid #cfdae5;
  border-bottom: 1px solid #cfdae5;
  border-radius: 0;
  background: #ffffff;
  color: #334155;
  text-align: center;
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.sudoku-cell:nth-child(9n) {
  border-right: 0;
}

.sudoku-cell:nth-child(n+73) {
  border-bottom: 0;
}

.sudoku-cell.has-block-right {
  border-right: 3px solid #27313a;
}

.sudoku-cell.has-block-bottom {
  border-bottom: 3px solid #27313a;
}

.sudoku-cell.is-fixed {
  background: #f3f7fb;
  color: #1f2933;
}

.sudoku-cell.is-peer {
  background: #edf6ff;
}

.sudoku-cell.is-selected {
  outline: 3px solid #2f80ed;
  outline-offset: -3px;
  background: #d9ecff;
}

.sudoku-cell.is-same-number {
  background: #dbeafe;
  color: #1d4ed8;
}

.sudoku-cell.is-user-value {
  color: #2563eb;
}

.sudoku-cell.is-wrong {
  background: #ffe4e6;
  color: #be123c;
}

.sudoku-keypad {
  width: min(100%, 560px);
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
}

.sudoku-keypad button,
.sudoku-actions button {
  min-height: 44px;
  border: 1px solid #c7d3df;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2933;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.sudoku-keypad button {
  color: #2563eb;
  font-size: 1.25rem;
}

.sudoku-keypad button:hover,
.sudoku-actions button:hover {
  background: #eef6ff;
}

.sudoku-actions {
  width: min(100%, 560px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.thread-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: rgba(255, 255, 255, 0.55);
}

.giggers-shell {
  display: grid;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr);
}

.giggers-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 250, 242, 0.82);
  border-bottom: 1px solid var(--line);
}

.giggers-theme {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--soft);
  font-weight: 800;
}

.giggers-theme select {
  min-height: 38px;
  border: 1px solid rgba(47, 43, 40, 0.14);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  font: inherit;
  font-weight: 800;
}

.giggers-note {
  margin: 0;
  color: var(--soft);
  font-weight: 700;
  line-height: 1.5;
  text-align: right;
}

.giggers-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
}

.snake-board {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  width: min(100%, 520px, calc(100svh - 310px));
  min-width: min(100%, 260px);
  aspect-ratio: 1;
  margin: 0 auto;
  gap: 2px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(47, 43, 40, 0.18);
}

.snake-board span {
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.52);
}

.snake-board .snake-body {
  background: var(--sea);
}

.snake-board .snake-food {
  background: var(--coral);
}

.game-inline-note {
  margin: 0;
  color: var(--soft);
  text-align: center;
}

.game-token {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92px;
  height: 92px;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  box-shadow: var(--shadow);
  user-select: none;
}

.memory-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  width: min(520px, calc(100% - 28px));
  margin: 18px auto;
}

.memory-card {
  aspect-ratio: 1;
  border: 0;
  border-radius: 8px;
  background: var(--sea);
  color: transparent;
  cursor: pointer;
  font-size: clamp(1.6rem, 6vw, 2.5rem);
}

.memory-card.is-open,
.memory-card.is-matched {
  background: #fff;
  color: var(--text);
}

.catch-player {
  position: absolute;
  left: 50%;
  bottom: 20px;
  width: 96px;
  height: 24px;
  border-radius: 8px;
  background: var(--coral);
  transform: translateX(-50%);
}

.falling-point {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--sun);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.game-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.game-controls p {
  margin: 0;
  color: var(--soft);
}

.rank-panel {
  display: grid;
  gap: 14px;
}

.rank-card {
  padding: 16px;
}

.wallet-balance {
  margin: 0.35rem 0;
  font-size: 2.4rem;
  font-weight: 800;
}

.wallet-note {
  margin: 0;
  color: var(--soft);
  line-height: 1.6;
}

.reward-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.reward-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.reward-item span {
  color: var(--soft);
  line-height: 1.5;
}

.reward-item em {
  color: #8d4b2b;
  font-style: normal;
  font-weight: 800;
}

.reward-item:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.reward-pending {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px dashed rgba(47, 43, 40, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
}

.reward-pending span {
  color: var(--soft);
  line-height: 1.55;
}

.unlock-panel {
  display: grid;
  gap: 18px;
}

.unlock-cost {
  color: #8d4b2b;
  font-size: 1.2rem;
  font-weight: 800;
}

.ranking-list {
  margin: 12px 0 0;
  padding-left: 24px;
}

.ranking-list li {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.ranking-list span {
  color: var(--soft);
}

@media (max-width: 920px) {
  .game-showcase,
  .game-header,
  .play-heading,
  .game-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .game-showcase,
  .play-layout,
  .auth-grid,
  .creator-call {
    grid-template-columns: 1fr;
  }

  .score-box {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .game-app {
    width: min(100% - 18px, 1180px);
    padding-top: 14px;
  }

  .game-library-grid,
  .game-spotlight-meta {
    grid-template-columns: 1fr;
  }

  .game-library-header {
    align-items: start;
    flex-direction: column;
  }

  .game-stage {
    min-height: 320px;
  }

  .game-stage.is-othello {
    min-height: 0;
  }

  .game-stage.is-sudoku {
    min-height: 0;
  }

  .game-stage.is-giggers {
    min-height: 380px;
    height: 72vh;
  }

  .game-stage.is-snake {
    min-height: 0;
    padding: 8px;
  }

  .snake-board {
    width: min(100%, calc(100svh - 330px));
    min-width: 0;
    gap: 1px;
    padding: 6px;
  }

  .othello-toolbar,
  .sudoku-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .othello-difficulty,
  .sudoku-difficulty {
    justify-content: space-between;
  }

  .othello-difficulty select,
  .sudoku-difficulty select {
    min-width: 9em;
  }

  .sudoku-note {
    text-align: left;
  }

  .sudoku-shell {
    padding: 10px;
  }

  .sudoku-cell {
    font-size: 1.35rem;
  }

  .sudoku-keypad {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .giggers-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .giggers-theme {
    justify-content: space-between;
  }

  .giggers-note {
    text-align: left;
  }

  .memory-board {
    gap: 7px;
  }
}
