@font-face {
  font-family: "RyeLocal";
  src: local("Rye"), local("Georgia");
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  align-items: center;
  background: radial-gradient(
    circle at top,
    #f7c96b 0%,
    #91441e 45%,
    #221009 100%
  );
  display: flex;
  font-family: Arial, Helvetica, sans-serif;
  height: 100vh;
  height: 100dvh;
  justify-content: center;
  margin: 0;
  overflow: hidden;
}

button,
a {
  cursor: pointer;
}

.app-shell {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  width: 100%;
}

.home-screen {
  align-items: center;
  background-image:
    linear-gradient(rgba(40, 17, 6, 0.35), rgba(40, 17, 6, 0.65)),
    url("img/5_background/complete_background.png");
  background-position: center;
  background-size: cover;
  display: flex;
  height: 100%;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
  width: 100%;
}

.hero-card,
.legal-card {
  background: rgba(255, 244, 210, 0.94);
  border: 4px solid #6e2d13;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  max-width: 620px;
  padding: 28px;
  text-align: center;
}

.eyebrow {
  color: #6e2d13;
  font-weight: 700;
  letter-spacing: 4px;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1,
h2 {
  color: #6e2d13;
  font-family: "RyeLocal", Georgia, serif;
  margin: 0 0 16px;
}

h1 {
  font-size: clamp(40px, 8vw, 78px);
  line-height: 0.95;
}

.start-image {
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  display: block;
  margin: 18px auto;
  max-height: 34vh;
  max-width: 100%;
  object-fit: contain;
  width: 480px;
}

.hero-text {
  color: #3a1b0d;
  font-size: 18px;
  line-height: 1.5;
  margin: 0 auto 24px;
}

.button-row,
.game-toolbar {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.game-toolbar {
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.toolbar-button,
.touch-button {
  border: 0;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  padding: 12px 22px;
}

.primary-button {
  background: #c42b16;
  color: #fff8dc;
}

.secondary-button,
.toolbar-button,
.touch-button {
  background: #ffe7a0;
  color: #5a260f;
}

.primary-button:hover,
.secondary-button:hover,
.toolbar-button:hover,
.touch-button:hover {
  filter: brightness(1.06);
}

.legal-link {
  color: #5a260f;
  display: inline-block;
  font-weight: 700;
  margin-top: 20px;
}

.hidden {
  display: none !important;
}

.game-screen {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  justify-content: center;
  overflow: hidden;
  padding: 14px;
  width: 100%;
}

.canvas-wrapper {
  position: relative;
}

canvas {
  background: #7ec8ee;
  border: 4px solid #4d200d;
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  display: block;
  height: auto;
  max-height: calc(100dvh - 116px);
  max-width: 96vw;
  width: min(720px, 96vw);
}

.end-screen-overlay {
  align-items: center;
  background: rgba(34, 16, 9, 0.72);
  border-radius: 16px;
  display: flex;
  inset: 4px;
  justify-content: center;
  position: absolute;
  z-index: 10;
}

.end-screen-card {
  background: rgba(255, 244, 210, 0.96);
  border: 4px solid #6e2d13;
  border-radius: 24px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  color: #3a1b0d;
  max-width: 460px;
  padding: 24px;
  text-align: center;
}

.image-card {
  padding: 20px;
}

.end-screen-image {
  display: block;
  margin: 0 auto 14px;
  max-height: 210px;
  max-width: 100%;
  object-fit: contain;
}

.end-screen-card h2 {
  font-size: 42px;
}

.end-screen-card p {
  font-size: 18px;
  line-height: 1.45;
}

.help-dialog {
  background: #fff3c4;
  border: 4px solid #6e2d13;
  border-radius: 22px;
  color: #3a1b0d;
  max-width: 520px;
  padding: 28px;
}

.help-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dialog-close {
  background: #c42b16;
  border: 0;
  border-radius: 50%;
  color: white;
  font-size: 28px;
  height: 42px;
  position: absolute;
  right: 12px;
  top: 12px;
  width: 42px;
}

.mobile-controls {
  display: none;
  gap: 18px;
  justify-content: center;
  touch-action: none;
}

.touch-button {
  font-size: 28px;
  height: 58px;
  user-select: none;
  width: 72px;
}

.rotate-device {
  align-items: center;
  background: #221009;
  color: #fff3c4;
  display: none;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  text-align: center;
  z-index: 20;
}

.legal-page {
  align-items: flex-start;
  height: auto;
  justify-content: center;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px;
}

.legal-page .legal-card {
  margin: 24px auto;
  max-width: 760px;
  padding: 24px 32px;
  width: min(760px, 94vw);
}

.legal-page h1 {
  font-size: clamp(48px, 7vw, 82px);
  margin-bottom: 18px;
}

.legal-page h2 {
  font-size: 26px;
  margin: 22px 0 8px;
}

.legal-page p {
  font-size: 17px;
  line-height: 1.35;
  margin: 8px 0;
}

.inline-link {
  display: inline-block;
  margin-top: 18px;
  text-decoration: none;
}

:fullscreen .game-screen {
  background: radial-gradient(
    circle at top,
    #f7c96b 0%,
    #91441e 45%,
    #221009 100%
  );
}

:fullscreen canvas {
  max-height: calc(100dvh - 96px);
  width: min(96vw, 960px);
}

@media (max-height: 660px) {
  .hero-card {
    padding: 20px;
  }

  .start-image {
    margin: 12px auto;
    max-height: 28vh;
  }

  .hero-text {
    font-size: 16px;
    margin-bottom: 16px;
  }

  .primary-button,
  .secondary-button,
  .toolbar-button,
  .touch-button {
    font-size: 16px;
    padding: 10px 18px;
  }

  canvas {
    max-height: calc(100dvh - 96px);
  }
}

@media (pointer: coarse), (max-width: 900px) {
  .mobile-controls {
    display: flex;
  }

  .game-toolbar {
    position: fixed;
    right: 12px;
    top: 12px;
    z-index: 5;
  }

  .toolbar-button {
    font-size: 14px;
    padding: 10px 14px;
  }

  canvas {
    max-height: calc(100dvh - 98px);
  }
}

@media (orientation: portrait) and (max-width: 900px) {
  .rotate-device {
    display: flex;
  }
}

@media (max-width: 700px) {
  .legal-page {
    padding: 12px;
  }

  .legal-page .legal-card {
    padding: 20px;
  }

  .legal-page h1 {
    font-size: 46px;
  }

  .legal-page h2 {
    font-size: 23px;
  }

  .legal-page p {
    font-size: 16px;
  }
}
