/* The daily puzzle page (/daily). */
body.play { min-height: 100dvh; }
#app { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.screen { padding: 12px 0 40px; display: flex; flex-direction: column; gap: 14px; }
.screen.center { align-items: center; justify-content: center; min-height: 70dvh; text-align: center; gap: 16px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; border: 0; background: transparent; cursor: pointer; color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--card-pressed); }
.icon-btn.placeholder { visibility: hidden; }
.icon-btn.flip .icon { transform: scaleX(-1); }

.row-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.row-buttons > .btn { flex: 1 1 0; }

/* Top bar */
.top-bar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; min-height: 56px; }
.top-title { text-align: center; min-width: 0; }
.top-title h1 { font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-sub { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.3em; }

/* Game */
.screen.game { height: 100dvh; padding: 0 0 max(12px, env(safe-area-inset-bottom)); gap: 0; }
.board-wrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 0 16px; }
.board-box { width: 300px; height: 300px; }
.game-bottom { position: relative; min-height: 96px; }
.toolbar { display: flex; justify-content: space-around; align-items: flex-start; }
.toolbar.hidden { visibility: hidden; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; cursor: pointer; padding: 4px 8px; -webkit-tap-highlight-color: transparent; }
.tool-circle { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); transition: transform .1s; }
.tool:active .tool-circle { transform: scale(.94); }
.tool:hover .tool-circle { background: var(--card-pressed); }
.tool-label { font-size: 14px; font-weight: 700; color: var(--muted); }
.tool[disabled] { opacity: .38; pointer-events: none; }
.sheet-slot { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; }
.sheet-slot:empty { display: none; }

.hint-card { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 16px 12px 16px 18px; animation: rise .22s ease-out; }
.hint-bulb { color: var(--warm); padding-top: 2px; }
.hint-body { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.hint-body p { font-size: 16px; }
.hint-card .icon-btn { margin: -8px -4px 0 0; }

.win-card { display: grid; grid-template-columns: 84px 1fr; gap: 6px 16px; align-items: center; animation: rise .3s ease-out; }
.win-pet { width: 84px; height: 84px; }
.win-text h2 { font-size: 28px; font-weight: 900; }
.win-stats { font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.win-card .row-buttons { grid-column: 1 / -1; margin-top: 10px; }
.link-btn { grid-column: 1 / -1; justify-self: center; background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; padding: 6px; font-size: 15px; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Modals */
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 6, 20, .45); display: grid; place-items: end center; animation: fade .15s ease-out; }
@media (min-width: 640px) { .modal-overlay { place-items: center; padding: 24px; } }
.modal {
  background: var(--bg); width: 100%; max-width: 520px; max-height: 92dvh; overflow: auto;
  border-radius: 26px 26px 0 0; padding: 8px 20px max(24px, env(safe-area-inset-bottom));
  animation: rise .22s ease-out;
}
.modal.wide { max-width: 620px; }
@media (min-width: 640px) { .modal { border-radius: 26px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 1; }
.modal-head h2 { font-size: 22px; font-weight: 900; }
@keyframes fade { from { opacity: 0; } }

.settings { display: flex; flex-direction: column; gap: 10px; }
.settings h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 12px; font-weight: 800; }
.toggle-row { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 16px; padding: 12px 16px; cursor: pointer; position: relative; }
.toggle-row > span:first-child { flex: 1; display: flex; flex-direction: column; }
.toggle-label { font-weight: 700; }
.toggle-row small { color: var(--muted); font-size: 13px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 51px; height: 31px; border-radius: 16px; background: var(--sep); position: relative; flex: none; transition: background .18s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .18s; }
.toggle-row input:checked + .switch { background: var(--accent); }
.toggle-row input:checked + .switch::after { transform: translateX(20px); }
.toggle-row input:focus-visible + .switch { outline: 3px solid var(--accent); outline-offset: 2px; }
.toggle-row[hidden] { display: none; }


/* Help */
.help .rules { list-style: none; padding: 0; margin: 4px 0 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.help .rules li { background: var(--card); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.help .rules strong { font-weight: 800; }
.help .rules p { color: var(--muted); font-size: 15px; }
.help-board { width: 100%; max-width: 160px; }
.controls-help { display: flex; flex-direction: column; gap: 10px; background: var(--card); border-radius: 18px; padding: 16px; font-size: 16px; }
kbd { font-family: inherit; font-size: 13px; font-weight: 800; background: var(--bg-2); border-radius: 6px; padding: 1px 6px; box-shadow: inset 0 -1px 0 var(--sep); }
@media (pointer: coarse) { .kbd-help { display: none; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 40px); opacity: 0; z-index: 60;
  background: #1D1A22; color: #fff; padding: 12px 20px; border-radius: 14px; font-weight: 700;
  transition: transform .2s, opacity .2s; pointer-events: none; max-width: calc(100% - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 380px) {
  .tool-circle { width: 54px; height: 54px; }
  .win-card { grid-template-columns: 64px 1fr; }
  .win-pet { width: 64px; height: 64px; }
}
@media (min-width: 900px) {
  #app { max-width: 720px; }
}
