:root {
  color-scheme: dark;
  --bg: #090913;
  --panel: #141424;
  --panel-2: #19192d;
  --line: #313154;
  --text: #f7f7ff;
  --muted: #b8b8d2;
  --cyan: #41f0ff;
  --pink: #ff4fd8;
  --yellow: #ffe75b;
  --green: #83ff7d;
  --red: #ff5b6f;
  --shadow: 0 20px 70px rgba(0, 0, 0, .45);
  font-family: Inter, "Segoe UI", Arial, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }

[hidden] { display: none !important; }

body {
  background:
    radial-gradient(circle at 15% 18%, rgba(255, 79, 216, .18), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(65, 240, 255, .16), transparent 25%),
    linear-gradient(135deg, #070710 0%, #101024 48%, #080812 100%);
  letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
  background: rgba(8, 8, 18, .82);
  border-bottom: 1px solid rgba(255, 255, 255, .11);
}

.topbar-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 210px;
  font-weight: 900;
  font-size: 1.12rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 2px solid var(--cyan);
  display: grid;
  place-items: center;
  color: var(--yellow);
  box-shadow: 0 0 22px rgba(65, 240, 255, .35), inset 0 0 20px rgba(255, 79, 216, .16);
}

.nav, .languages {
  display: flex;
  align-items: center;
  gap: 14px;
  row-gap: 8px;
  color: var(--muted);
  font-size: .94rem;
}

.languages {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a, .languages a {
  padding: 8px 0;
  border-bottom: 2px solid transparent;
}

.nav a:hover, .languages a:hover, .languages a.active {
  color: var(--text);
  border-color: var(--cyan);
}

.hero {
  position: relative;
  padding: 54px 0 34px;
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 26px;
  align-items: stretch;
}

.hero-main, .side-panel, .game-card, .ad-slot, .content-panel {
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(16, 16, 34, .82);
  box-shadow: var(--shadow);
}

.hero-main {
  min-height: 336px;
  padding: clamp(26px, 5vw, 56px);
  position: relative;
  overflow: hidden;
}

.hero-main::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(65, 240, 255, .13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(65, 240, 255, .13) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(90deg, black, transparent 82%);
  opacity: .55;
}

.eyebrow {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--cyan);
  font-weight: 800;
  text-transform: uppercase;
  font-size: .82rem;
}

.eyebrow::before {
  content: "";
  width: 42px;
  height: 2px;
  background: var(--cyan);
}

h1 {
  position: relative;
  margin: 26px 0 18px;
  max-width: 720px;
  font-size: clamp(3.1rem, 9vw, 7.2rem);
  line-height: .88;
  text-transform: uppercase;
  letter-spacing: 0;
}

.game-title {
  font-size: clamp(2.4rem, 5vw, 4.6rem);
  line-height: .94;
  max-width: 760px;
}

.game-page-section {
  padding-top: 26px;
}

.hero-copy {
  position: relative;
  max-width: 640px;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.22rem);
  line-height: 1.75;
}

.hero-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button {
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid rgba(255, 255, 255, .22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  background: rgba(255, 255, 255, .07);
}

.button.primary {
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  color: #080812;
  border: 0;
}

.side-panel { padding: 18px; display: grid; align-content: space-between; gap: 16px; }

.arcade-screen {
  min-height: 210px;
  padding: 18px;
  border: 1px solid rgba(65, 240, 255, .34);
  background: #0d0d18;
  position: relative;
  overflow: hidden;
}

.screen-title { color: var(--yellow); font-family: Consolas, monospace; font-size: .9rem; margin-bottom: 12px; }

.pixel-scene {
  height: 154px;
  display: grid;
  place-items: end center;
  background:
    linear-gradient(transparent 86%, rgba(65, 240, 255, .28) 87%, transparent 88%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.03), rgba(255,255,255,.03) 1px, transparent 1px, transparent 5px);
}

.mini-stack { display: grid; gap: 4px; justify-items: center; }
.rice { width: 68px; height: 36px; background: #f6f0df; clip-path: polygon(50% 0, 100% 100%, 0 100%); border: 3px solid #10101d; position: relative; }
.rice::after { content: ""; position: absolute; left: 25px; bottom: 4px; width: 18px; height: 12px; background: #111; }
.plate { width: 120px; height: 14px; background: var(--pink); border: 3px solid #111; }

.ad-slot {
  min-height: 96px;
  display: grid;
  place-items: center;
  color: rgba(247, 247, 255, .48);
  font-size: .78rem;
  text-transform: uppercase;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.05), rgba(255,255,255,.05) 8px, rgba(255,255,255,.025) 8px, rgba(255,255,255,.025) 16px);
}

.section { padding: 30px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.3rem); }
.section-note { color: var(--muted); max-width: 560px; line-height: 1.7; }

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

.game-card { padding: 18px; min-height: 190px; display: grid; gap: 12px; align-content: space-between; }
.game-card.featured { border-color: rgba(255, 231, 91, .55); }
.game-card h3 { margin: 0; font-size: 1.18rem; }
.game-card p { margin: 0; color: var(--muted); line-height: 1.65; }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { border: 1px solid rgba(255,255,255,.17); padding: 4px 8px; color: var(--cyan); font-size: .78rem; font-weight: 800; }

.game-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
  align-items: start;
}

.game-shell {
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(9, 9, 19, .88);
  box-shadow: var(--shadow);
  padding: 18px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.hud-item { background: var(--panel-2); border: 1px solid var(--line); padding: 10px; min-height: 62px; }
.hud-label { color: var(--muted); font-size: .76rem; text-transform: uppercase; }
.hud-value { color: var(--yellow); font-size: 1.35rem; font-weight: 900; margin-top: 4px; }

.playfield-wrap {
  position: relative;
  aspect-ratio: 10 / 13;
  max-height: 680px;
  min-height: 420px;
  border: 3px solid rgba(65, 240, 255, .45);
  background: #101020;
  overflow: hidden;
}

#gameCanvas { width: 100%; height: 100%; display: block; touch-action: manipulation; }

.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 8, 18, .76);
  padding: 20px;
}

.overlay-card {
  width: min(460px, 100%);
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(20,20,36,.96);
  padding: 22px;
  text-align: center;
}

.overlay-card h2 { margin: 0 0 12px; font-size: 1.9rem; }
.overlay-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.7; }

.game-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.blocks-layout .game-shell {
  max-width: 720px;
}

.block-hud .small-hud {
  font-size: .92rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.block-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
}

.mode-choice {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .07);
  color: var(--text);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.mode-choice.active {
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  color: #080812;
  border-color: transparent;
}

.block-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(96px, 150px);
  gap: 14px;
  align-items: start;
  justify-content: center;
  padding: 14px;
  border: 3px solid rgba(65, 240, 255, .45);
  background: #101020;
  overflow: hidden;
}

#blockCanvas {
  width: 100%;
  aspect-ratio: 1 / 2;
  display: block;
  background: #090913;
  touch-action: none;
}

.next-panel {
  display: grid;
  gap: 10px;
  align-content: start;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

#nextCanvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  border: 1px solid rgba(255,255,255,.16);
  background: #090913;
}

.block-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 1fr));
  gap: 10px;
  margin-top: 14px;
  overscroll-behavior: contain;
  touch-action: none;
}

.block-controls button {
  min-height: 50px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 900;
  touch-action: none;
  user-select: none;
}

.sudoku-layout .game-shell {
  max-width: 760px;
}

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

.sudoku-toolbar {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) repeat(5, minmax(90px, auto));
  gap: 10px;
  margin-bottom: 14px;
}

.sudoku-toolbar select,
.sudoku-toolbar button {
  width: 100%;
  min-height: 44px;
}

.sudoku-toolbar select {
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.08);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-weight: 900;
}

.sudoku-board-wrap {
  display: grid;
  place-items: center;
  padding: 14px;
  border: 3px solid rgba(65, 240, 255, .45);
  background:
    linear-gradient(135deg, rgba(65,240,255,.08), rgba(255,79,216,.08)),
    #101020;
  overflow: hidden;
  touch-action: none;
}

.sudoku-board {
  width: min(100%, 540px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 3px solid rgba(247,247,255,.82);
  background: rgba(247,247,255,.82);
  gap: 1px;
  user-select: none;
  touch-action: none;
}

.sudoku-cell {
  min-width: 0;
  min-height: 0;
  border: 0;
  background: rgba(9, 9, 19, .98);
  color: var(--text);
  font: inherit;
  font-weight: 900;
  font-size: clamp(1.05rem, 4.2vw, 2rem);
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  touch-action: none;
}

.sudoku-cell:nth-child(3n) { border-right: 2px solid rgba(247,247,255,.82); }
.sudoku-cell:nth-child(9n) { border-right: 0; }
.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid rgba(247,247,255,.82); }

.sudoku-cell.given {
  color: var(--yellow);
  background: rgba(25,25,45,.98);
}

.sudoku-cell.selected {
  outline: 3px solid var(--cyan);
  z-index: 2;
}

.sudoku-cell.peer {
  background: rgba(65, 240, 255, .12);
}

.sudoku-cell.same {
  color: var(--cyan);
}

.sudoku-cell.error {
  background: rgba(255, 91, 111, .28);
  color: #fff;
}

.sudoku-cell.hinted {
  animation: sudokuPulse .7s ease;
}

.sudoku-notes {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  color: rgba(247,247,255,.62);
  font-size: clamp(.48rem, 1.6vw, .72rem);
  line-height: 1;
  padding: 4px;
}

.sudoku-pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
  margin-top: 14px;
  touch-action: none;
}

.sudoku-pad button {
  min-height: 48px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 900;
  touch-action: none;
  user-select: none;
}

.sudoku-pad button.active {
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  color: #080812;
}

.sudoku-status {
  min-height: 28px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.renju-layout .game-shell {
  max-width: 780px;
}

.renju-hud {
  grid-template-columns: repeat(3, 1fr);
}

.renju-toolbar {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) repeat(3, minmax(100px, auto));
  gap: 10px;
  margin-bottom: 14px;
}

.renju-toolbar select,
.renju-toolbar button {
  width: 100%;
  min-height: 44px;
}

.renju-toolbar select {
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.08);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-weight: 900;
}

.renju-board-wrap {
  display: grid;
  place-items: center;
  padding: 14px;
  border: 3px solid rgba(65, 240, 255, .45);
  background:
    radial-gradient(circle at 50% 40%, rgba(255,231,91,.12), transparent 34%),
    linear-gradient(135deg, rgba(65,240,255,.1), rgba(255,79,216,.08)),
    #101020;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: contain;
}

#renjuCanvas {
  width: min(100%, 620px);
  aspect-ratio: 1 / 1;
  display: block;
  background: #111522;
  border: 1px solid rgba(255,255,255,.18);
  touch-action: none;
  user-select: none;
}

.renju-status {
  min-height: 30px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

@keyframes sudokuPulse {
  0% { box-shadow: inset 0 0 0 0 rgba(131,255,125,.8); }
  100% { box-shadow: inset 0 0 0 999px rgba(131,255,125,0); }
}

.content-panel { padding: 22px; line-height: 1.75; color: var(--muted); }
.content-panel h2, .content-panel h3 { color: var(--text); line-height: 1.25; }

.footer {
  margin-top: 40px;
  padding: 28px 0;
  border-top: 1px solid rgba(255,255,255,.12);
  color: rgba(247,247,255,.58);
  font-size: .9rem;
}

.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-links { display: inline-flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.footer a { color: rgba(247,247,255,.72); }

@media (max-width: 920px) {
  .topbar-inner { align-items: flex-start; flex-direction: column; padding: 14px 0; }
  .nav, .languages { flex-wrap: wrap; }
  .hero-grid, .game-layout { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .hud { grid-template-columns: repeat(2, 1fr); }
  .playfield-wrap { min-height: 480px; }
  .block-stage { grid-template-columns: minmax(210px, 1fr) 96px; }
  .sudoku-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sudoku-hud { grid-template-columns: repeat(3, 1fr); }
  .renju-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .renju-hud { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 22px, 1180px); }
  .hero { padding-top: 24px; }
  .hero-main { padding: 24px 18px; min-height: 300px; }
  h1 { font-size: clamp(2.7rem, 16vw, 4.2rem); }
  .game-title { font-size: clamp(2.4rem, 13vw, 3.5rem); }
  .button { width: 100%; }
  .playfield-wrap { min-height: 420px; }
  .block-stage { grid-template-columns: minmax(190px, 1fr) 78px; gap: 10px; padding: 10px; }
  .block-controls { grid-template-columns: repeat(5, minmax(44px, 1fr)); gap: 8px; }
  .block-controls button { min-height: 46px; }
  .sudoku-shell { padding: 12px; }
  .sudoku-hud { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .sudoku-hud .hud-item { padding: 8px 6px; min-height: 58px; }
  .sudoku-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .sudoku-board-wrap { padding: 8px; }
  .sudoku-pad { grid-template-columns: repeat(5, 1fr); gap: 7px; }
  .sudoku-pad button { min-height: 44px; }
  .renju-shell { padding: 12px; }
  .renju-hud { gap: 6px; }
  .renju-hud .hud-item { padding: 8px 6px; min-height: 58px; }
  .renju-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .renju-board-wrap { padding: 8px; }
}
