@charset "UTF-8";

:root {
  color-scheme: light;
  --green: #e9f0db;
  --deep-green: #3b6044;
  --ink: #304b38;
  --red: #c9513e;
  --cell-gap: 3px;
  --cell-size: min(72px, calc((100vw - 88px - 16 * var(--cell-gap)) / 17), calc((100dvh - 106px - 9 * var(--cell-gap)) / 10));
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  background: #dce7cd;
  color: var(--ink);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans CJK KR", sans-serif;
}
button { font: inherit; }
button:focus-visible { outline: 3px solid #79382d; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.game-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 270px;
  padding: max(9px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(9px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  overflow: hidden;
  background: radial-gradient(ellipse at 48% 40%, #f3f7ea 0%, #e7efda 66%, #d4e3c6 100%);
}
.hud { position: relative; z-index: 1; flex: none; display: flex; align-items: center; justify-content: space-between; height: 42px; padding: 0 9px; }
.home-button { display: grid; place-items: center; width: 38px; height: 36px; border: 1px solid #a8bc9d; border-radius: 10px; background: #f9fbee; color: var(--ink); font-family: Georgia, serif; font-size: 27px; line-height: 1; cursor: pointer; box-shadow: 0 2px 0 #b3c9a9; }
.home-button:hover { background: #fff; }
.hud-stats { display: flex; align-items: center; gap: clamp(7px, 2vw, 24px); }
.hud-stat { display: flex; align-items: baseline; gap: 7px; color: #31523b; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud-label { font-size: clamp(11px, 1.7vw, 14px); font-weight: 800; }
.hud-stat strong { min-width: 2ch; font-family: Georgia, "Malgun Gothic", serif; font-size: clamp(18px, 2.6vw, 23px); }
#time-progress { display: block; flex: none; width: clamp(58px, 17vw, 180px); height: 10px; overflow: hidden; appearance: none; -webkit-appearance: none; border: 1px solid #9db790; border-radius: 99px; background: #cddfc3; }
#time-progress::-webkit-progress-bar { border-radius: 99px; background: #cddfc3; }
#time-progress::-webkit-progress-value { border-radius: 99px; background: linear-gradient(90deg, #eab95c, #d16d43); }
#time-progress::-moz-progress-bar { border-radius: 99px; background: linear-gradient(90deg, #eab95c, #d16d43); }
.is-home .hud { visibility: hidden; }

.orchard {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid #b8cfaa;
  border-radius: clamp(16px, 3vw, 30px);
  background: radial-gradient(ellipse at 50% 32%, #eff5e5 0%, #e0edcf 70%, #cee2be 100%);
  box-shadow: inset 0 2px 12px #ffffffb5, inset 0 -5px 18px #a4c79550, 0 5px 16px #577a4b20;
}
.orchard::before { content: ""; position: absolute; inset: 0; opacity: .35; pointer-events: none; background-image: radial-gradient(#6f9c742c .8px, transparent .8px); background-size: 10px 10px; }
.board-scroller { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 7px; overflow: auto; scrollbar-color: #86ab78 #d8e9cc; scrollbar-width: thin; touch-action: pan-x; }
#board { display: grid; flex: none; grid-template-columns: repeat(17, var(--cell-size)); grid-template-rows: repeat(10, var(--cell-size)); grid-auto-rows: var(--cell-size); gap: var(--cell-gap); width: max-content; margin: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.apple {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--cell-size);
  height: var(--cell-size);
  padding: 0;
  border: max(1px, calc(var(--cell-size) / 20)) solid #f9d8b4;
  border-radius: 43% 43% 46% 46%;
  background: radial-gradient(circle at 31% 23%, #fff4cf 0%, #ffdcab 49%, #e9ab78 100%);
  box-shadow: 0 2px 0 #9bba8d, inset -3px -3px 0 #ca8b6644, inset 2px 2px 0 #fff9e6;
  color: #682f26;
  font-family: Georgia, "Malgun Gothic", serif;
  font-size: clamp(12px, calc(var(--cell-size) * .49), 21px);
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, background .12s ease;
}
.apple::before { content: ""; position: absolute; top: -4px; left: 48%; width: 2px; height: 6px; border-radius: 3px; background: #5e422e; transform: rotate(19deg); }
.apple::after { content: ""; position: absolute; top: -4px; left: 54%; width: 7px; height: 5px; border-radius: 100% 0 100% 0; background: #87a05b; transform: rotate(-28deg); }
.apple:hover:not(.empty):not(:disabled) { transform: translateY(-2px); }
.apple.selected { z-index: 1; color: #3d2817; background: #f8c452; border-color: #fff4b5; box-shadow: 0 0 0 2px #d8a73e, inset -3px -3px 0 #dc9b3a; transform: translateY(-1px); }
.apple.empty { border-color: #a9c59966; background: #bed7ae50; box-shadow: inset 0 1px 3px #71966133; color: transparent; }
.apple.empty.selected { border-color: #e8bb60; background: #f4d89080; box-shadow: 0 0 0 2px #d5a450, inset 0 1px 3px #ad8f48a6; }
.apple.empty::before, .apple.empty::after { display: none; }
.apple:focus-visible { z-index: 2; outline: 2px solid #773e2c; outline-offset: 1px; }

.screen-overlay { position: absolute; z-index: 3; inset: 0; display: grid; place-items: center; padding: 18px; background: #31574694; text-align: center; }
.overlay-content { display: flex; flex-direction: column; align-items: center; max-width: 100%; padding: 14px 25px; color: #fffcef; text-shadow: 0 2px 8px #22412d77; }
.overlay-leaf { color: #fae8a9; font-size: clamp(16px, 3vw, 28px); line-height: 1; margin-bottom: 5px; }
.overlay-content h1, .overlay-content h2 { margin: 0 0 19px; font-family: "Batang", "Nanum Myeongjo", "AppleMyungjo", Georgia, serif; font-size: clamp(39px, min(8vw, 13vh), 80px); line-height: 1.15; letter-spacing: -.09em; white-space: nowrap; }
.catalog-error { max-width: 28rem; margin: 0 0 16px; padding: 10px 14px; border: 1px solid #ffe4b8; border-radius: 10px; background: #5f2e24e6; color: #fff8e8; font-weight: 700; text-shadow: none; }
.catalog-error[hidden] { display: none; }
.action-button { min-width: 158px; min-height: 46px; padding: 9px 19px; border: 2px solid #fff8de; border-radius: 12px; background: #fff8de; color: #3e5940; box-shadow: 0 4px 0 #45654880; font-size: clamp(13px, 2.3vw, 17px); font-weight: 900; cursor: pointer; text-shadow: none; transition: transform .15s ease, background .15s ease; }
.action-button span { margin-left: 9px; }.action-button:hover { background: white; transform: translateY(-2px); }.action-button:active { transform: translateY(2px); box-shadow: none; }
.result-content h2 { margin-bottom: 4px; font-size: clamp(29px, min(5vw, 11vh), 58px); }
.result-label { margin: 4px 0 0; font-size: 14px; font-weight: 800; }
.result-score { display: flex; align-items: baseline; gap: 5px; margin: 0 0 14px; font-size: 18px; font-weight: 800; }
.result-score strong { font-family: Georgia, serif; font-size: clamp(43px, min(9vw, 14vh), 76px); line-height: 1.1; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.action-secondary { border-color: #fff8de; background: transparent; color: #fff8de; }.action-secondary:hover { background: #ffffff30; }

@media (orientation: portrait) {
  :root { --cell-size: clamp(27px, 7vw, 38px); --cell-gap: 3px; }
  .board-scroller { justify-content: flex-start; padding: 8px 8px 26px; }
  #board { margin: auto 0; }
  .orchard::after { content: "←  밀어서 이동  →"; position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%); color: #537e55; font-size: 11px; font-weight: 800; pointer-events: none; white-space: nowrap; }
}
@media (max-height: 400px) {
  .overlay-content { padding: 0 16px; }
  .overlay-leaf { margin-bottom: 2px; }
  .overlay-content h1 { margin-bottom: 10px; }
  .result-content h2 { margin-bottom: 0; }
  .result-score { margin-bottom: 7px; }
  .action-button { min-height: 36px; padding: 5px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .apple, .action-button { transition: none; }
}

.screen-overlay { overflow-y: auto; }
.session-copy { margin: 0 0 10px; max-width: 34rem; font-size: 13px; line-height: 1.5; word-break: keep-all; }
.nickname-form { width: min(100%, 390px); margin-bottom: 10px; text-align: left; text-shadow: none; }
.nickname-form label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 800; }
.nickname-row { display: flex; gap: 8px; }
.nickname-row input { width: 100%; min-width: 0; padding: 10px 12px; border: 2px solid #e5d7b7; border-radius: 10px; background: #fffcef; color: var(--ink); font: inherit; }
.nickname-row .action-button { min-width: 96px; }
.nickname-form p { margin: 8px 0 0; font-size: 11px; line-height: 1.6; color: #f1edda; }
.text-button { padding: 7px 10px; margin-top: 5px; border: 0; background: transparent; color: #fff8de; font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
button:disabled { opacity: .6; cursor: not-allowed; }
input:focus-visible { outline: 3px solid #f2ca74; outline-offset: 2px; }
.network-notice { position: absolute; z-index: 8; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100% - 24px); padding: 9px 12px; border: 1px solid #e2c8a0; border-radius: 10px; background: #fff5df; color: #503b29; font-size: 12px; box-shadow: 0 3px 15px #263c3140; }
.network-notice button, .ranking-panel button { flex: none; min-height: 34px; padding: 6px 12px; border: 1px solid #b5c4a6; border-radius: 8px; background: #f8f7e9; color: var(--ink); font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.ranking-overlay { z-index: 7; background: #254937bd; }
.ranking-panel { display: flex; flex-direction: column; width: min(100%, 520px); max-height: 100%; padding: 18px; border: 2px solid #bfd1ac; border-radius: 20px; background: #f2f6e6; color: var(--ink); box-shadow: 0 12px 50px #12392455; text-align: left; }
.ranking-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }.ranking-header h2 { margin: 0; font-family: "Batang", Georgia, serif; font-size: 24px; letter-spacing: -.06em; }
.ranking-tabs { display: flex; gap: 8px; margin: 15px 0 12px; }.ranking-tabs button { flex: 1; }.ranking-tabs [aria-selected="true"] { background: #456c48; color: #fff9df; border-color: #456c48; }
#ranking-content { min-height: 0; overflow-y: auto; font-size: 13px; }#ranking-state { margin: 0 0 10px; color: #657b58; line-height: 1.6; }.ranking-self { padding: 9px 12px; background: #e3ecd4; border-radius: 8px; }.ranking-self:empty { display: none; }
.ranking-list { margin: 0; padding: 0; list-style: none; }.ranking-list li { padding: 12px 8px; border-bottom: 1px solid #d5dfc9; overflow-wrap: anywhere; }
@media (max-height: 400px) {
  .overlay-content h1 { font-size: 36px; margin-bottom: 5px; }
  .session-copy { font-size: 11px; margin-bottom: 5px; }
  .nickname-form { margin-bottom: 3px; }.nickname-form p { margin-top: 4px; line-height: 1.4; }
  .ranking-panel { padding: 12px; }.ranking-tabs { margin: 8px 0; }
  .text-button { padding: 4px 10px; margin: 0; }
}
