:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", sans-serif;
  color: #fff8df;
  background: #10271c;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --gold: #e8c575;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100svh;
  background: radial-gradient(ellipse at 50% 20%, #28563a, #10271c 72%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button { font: inherit; }

.game-screen {
  width: 100%;
  height: 100svh;
  min-height: 420px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.game-header {
  width: min(100%, 600px);
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow { margin: 0 0 2px; color: #b9d7a5; font-size: 0.58rem; letter-spacing: 0.15em; }
.game-header h1 { margin: 0; font-size: clamp(1.1rem, 5vw, 1.5rem); line-height: 1.2; }

.reset-button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 16px;
  color: #203522;
  font-weight: 750;
  background: linear-gradient(#f7dfa0, var(--gold));
  border: 1px solid #fff0c3;
  border-radius: 12px;
  box-shadow: 0 3px 0 #94703b, 0 5px 14px #0004;
  cursor: pointer;
  touch-action: manipulation;
}
.reset-button:active { transform: translateY(2px); box-shadow: 0 1px 0 #94703b; }

.game-layout {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.board {
  position: relative;
  height: min(74svh, calc(100svh - 150px));
  max-height: 760px;
  width: auto;
  aspect-ratio: 941 / 1672;
  flex: 0 1 auto;
  overflow: hidden;
  border: 3px solid var(--gold);
  border-radius: 16px;
  background: linear-gradient(160deg, #92c875, #578d48 58%, #8e7048);
  box-shadow: 0 10px 30px #0008, inset 0 0 0 3px #173d2a66;
  touch-action: none;
}

.field-image, #game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.field-image { object-fit: contain; pointer-events: none; }
#game-canvas { z-index: 1; touch-action: none; cursor: grab; }
#game-canvas.is-dragging { cursor: grabbing; }

.image-warning {
  position: absolute;
  z-index: 2;
  top: 40%;
  left: 8%;
  width: 84%;
  padding: 8px;
  color: #fff;
  background: #2a180dcc;
  border: 1px solid #f2d17d;
  border-radius: 8px;
  text-align: center;
  font-size: 0.75rem;
  pointer-events: none;
}

.game-info { min-height: 34px; text-align: center; }
.game-info p { margin: 0; text-shadow: 0 1px 3px #000; }
#game-status { font-size: clamp(0.8rem, 3.4vw, 0.95rem); font-weight: 700; }
.game-info .hint { color: #d8e7c6; font-size: 0.72rem; }
.game-screen footer { color: #b9d7a5; text-align: center; font-size: 0.7rem; }

@media (min-width: 700px) {
  .game-screen { gap: 10px; }
  .board { height: min(76svh, calc(100svh - 180px)); }
}

@media (max-height: 560px) {
  .game-screen { padding-top: max(5px, env(safe-area-inset-top)); gap: 2px; }
  .game-header { min-height: 42px; }
  .board { height: calc(100svh - 112px); }
  .game-info { min-height: 27px; }
  .game-info .hint, .game-screen footer { display: none; }
}
