:root {
  --site-nav-bg: #09234a;
  --site-nav-text: #ffffff;
  --site-nav-accent: #63d4ff;
  --site-footer-bg: rgba(0, 0, 0, 0.2);
}

html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
}

.game-page *,
.home-page *,
.legal-page * {
  box-sizing: border-box;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: var(--site-nav-bg);
  color: var(--site-nav-text);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.25);
}

.site-nav {
  max-width: 1200px;
  min-height: 64px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-name {
  color: var(--site-nav-text);
  text-decoration: none;
  font-size: 21px;
  font-weight: 800;
  white-space: nowrap;
}

.site-menu {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.site-menu a {
  color: var(--site-nav-text);
  text-decoration: none;
  padding: 10px 9px;
  border-radius: 7px;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}

.site-menu a:hover,
.site-menu a:focus-visible {
  color: var(--site-nav-bg);
  background: var(--site-nav-accent);
  outline: none;
}

.site-menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  margin: 0 0 0 auto;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  background: transparent;
  color: var(--site-nav-text);
  font-size: 24px;
  line-height: 1;
}

.game-page {
  padding: 0 !important;
}

.game-page > .main-wrapper {
  width: 100%;
  max-width: 1400px;
  padding: 32px 20px 24px;
}

.game-title {
  margin: 0;
  color: #fff;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.15;
  text-align: center;
}

.game-title-wrap {
  width: min(100%, 760px);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
  align-items: center;
  gap: clamp(16px, 4vw, 36px);
}

.game-title-wrap .game-title {
  text-align: left;
}

.game-illustration {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
}

.game-card-art {
  display: block;
  margin: -6px -6px 2px;
  border-radius: 12px;
  overflow: hidden;
}

.game-card-art:focus-visible {
  outline: 3px solid #00bfff;
  outline-offset: 3px;
}

.game-card-art .game-illustration {
  transition: transform 0.2s ease;
}

.game-card-art:hover .game-illustration {
  transform: scale(1.025);
}

.help-game-name {
  margin: 0 0 30px;
  color: #00bfff;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
}

.game-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.game-nav-link {
  min-height: 44px;
  padding: 11px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #7ddcff;
  border-radius: 7px;
  background: #006da3;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.game-nav-link:hover,
.game-nav-link:focus-visible {
  border-color: #fff;
  background: #008fcf;
  color: #fff;
  outline: 3px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

.game-page .container,
.game-page .game-container,
.game-page .game-wrapper,
.game-page .grid-container,
.game-page .controls,
.game-page .content-section {
  max-width: 100%;
  min-width: 0;
}

.sanahaku-page .grid-container {
  width: min(100%, 560px);
}

.sanahaku-page #grid.grid {
  width: min(100%, 520px);
  grid-template-columns: repeat(10, minmax(0, 1fr));
}

.sanahaku-page .grid-cell {
  width: auto;
  height: auto;
  aspect-ratio: 1;
  font-size: clamp(17px, 4vw, 24px);
}

.sanapalapeli-page .game-container {
  width: min(100%, 760px);
  margin-inline: auto;
}

.sanapalapeli-page .grid {
  width: min(100%, 420px);
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sanapalapeli-page .grid > div {
  width: auto;
  height: auto;
  aspect-ratio: 1;
}

.sanalouhos-page .grid-container,
.sanalouhos-page #grid.grid {
  width: min(100%, 420px);
}

.sanalouhos-page #grid.grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sanalouhos-page .grid .cell {
  width: auto;
  height: auto;
  aspect-ratio: 1;
}

.sanapyramidi-page .pyramid-container {
  width: min(100%, 900px);
  margin-inline: auto;
}

.sanapyramidi-page .pyramid-row {
  width: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
}

.sanapyramidi-page .word-button {
  width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ristikko-page .crossword-container {
  width: min(100%, 680px);
}

.ristikko-page .crossword-grid {
  width: 100%;
  grid-template-columns: repeat(15, minmax(0, 1fr));
}

.ristikko-page .crossword-grid .cell {
  width: auto;
  height: auto;
  min-width: 0;
  aspect-ratio: 1;
}

.game-page .content-section {
  max-width: 900px;
  width: 100%;
  margin: 0 auto 30px;
}

.game-page .content-section p,
.game-page .content-section li {
  overflow-wrap: anywhere;
}

.help-accordion {
  width: min(100%, 960px);
  margin: 0 auto 30px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.help-accordion > summary {
  min-height: 56px;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.help-accordion > summary::before {
  content: "＋";
  margin-right: 10px;
}

.help-accordion[open] > summary::before {
  content: "−";
}

.help-content {
  padding: 0 14px 14px;
}

.site-footer {
  width: 100%;
  margin-top: 24px;
  padding: 24px 20px;
  text-align: center;
  background: var(--site-footer-bg);
}

.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
}

.site-footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer p {
  margin: 14px 0 0;
  font-size: 14px;
}

.privacy-notice {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 3000;
  width: min(430px, calc(100% - 32px));
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid #cfd8e6;
  border-radius: 10px;
  background: #fff;
  color: #14213d;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.24);
  font-family: Arial, sans-serif;
  line-height: 1.45;
}

.privacy-notice p {
  margin: 0;
  font-size: 14px;
}

.privacy-notice a {
  color: #0047ab;
}

.privacy-notice button {
  min-width: 64px;
  min-height: 44px;
  margin: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 7px;
  background: #0047ab;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.legal-page {
  margin: 0;
  background: #f4f7fb;
  color: #14213d;
  font-family: Arial, sans-serif;
  line-height: 1.65;
}

.legal-main {
  width: min(760px, calc(100% - 32px));
  margin: 40px auto;
  padding: 32px;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(24, 45, 80, 0.08);
}

.legal-main h1,
.legal-main h2 {
  color: #0047ab;
}

.legal-main a {
  color: #0047ab;
}

.sanalouhos-page svg.path-line {
  width: 100%;
  height: 100%;
}

@media (max-width: 760px) {
  .site-nav {
    position: relative;
    min-height: 58px;
    padding: 7px 14px;
  }

  .site-menu-toggle {
    display: inline-grid;
    place-items: center;
    cursor: pointer;
  }

  .site-menu {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    right: 10px;
    left: 10px;
    max-height: calc(100vh - 74px);
    overflow-y: auto;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0 0 10px 10px;
    background: var(--site-nav-bg);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  }

  .site-menu.is-open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-menu a {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
    text-align: center;
  }

  .game-page > .main-wrapper {
    gap: 24px;
    padding: 24px 12px 18px;
  }

  .game-title-wrap {
    grid-template-columns: 1fr;
    width: min(100%, 440px);
    gap: 14px;
  }

  .game-title-wrap .game-title {
    text-align: center;
  }

  .game-title-wrap .game-illustration {
    width: min(100%, 360px);
    margin-inline: auto;
  }

  .game-page .content-section {
    padding: 20px 16px;
  }

  .game-page input {
    max-width: 100%;
  }

  .game-page .grid {
    max-width: 100%;
  }

  .game-page .crossword-grid {
    width: min(100%, 525px);
    grid-template-columns: repeat(15, minmax(0, 1fr)) !important;
  }

  .game-page .crossword-grid .cell {
    width: auto !important;
    height: auto !important;
    min-width: 0;
    aspect-ratio: 1;
  }

  .game-page .crossword-grid .cell input {
    min-width: 0;
    font-size: clamp(12px, 4vw, 18px);
  }

  .game-page .clues-container {
    width: 100%;
    min-width: 0 !important;
  }

  .game-page .grid-cell {
    width: auto !important;
    height: auto !important;
    min-width: 0;
    aspect-ratio: 1;
    font-size: clamp(12px, 4.5vw, 19px);
  }

  .sanahaku-page #grid.grid {
    width: 100%;
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }

  .sanapalapeli-page .grid {
    width: min(100%, 420px);
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sanapalapeli-page .grid > div {
    min-width: 0;
    width: auto !important;
    height: auto !important;
    aspect-ratio: 1;
  }

  .sanalouhos-page #grid.grid {
    width: min(100%, 420px);
    max-width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sanalouhos-page .grid-container {
    width: min(100%, 420px);
    max-width: 100%;
  }

  .sanalouhos-page .icon-button {
    width: auto;
    min-width: 44px;
    padding: 0 10px;
  }

  .game-page .cell {
    max-width: 100%;
  }

  .game-page .grid .cell {
    width: auto !important;
    height: auto !important;
    min-width: 0;
    aspect-ratio: 1;
  }

  .game-page .pyramid-row {
    width: 100%;
  }

  .game-page .word-button {
    min-width: 0;
    max-width: 100%;
    padding: 10px 8px;
    overflow-wrap: anywhere;
    font-size: clamp(10px, 3vw, 14px);
  }

  .legal-main {
    margin: 24px auto;
    padding: 22px 18px;
  }

  .help-content {
    padding: 0 8px 8px;
  }

  .privacy-notice {
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
    align-items: flex-end;
  }
}

@media (max-width: 390px) {
  .site-name {
    font-size: 19px;
  }

  .site-menu.is-open {
    grid-template-columns: 1fr 1fr;
  }

  .game-page .crossword-grid {
    gap: 1px;
    padding: 3px;
  }

  .game-page .cell-number {
    font-size: 7px;
  }
}
