/* The page is only a frame for the canvas: no scrolling, no overscroll bounce,
   no text selection, and the game kept clear of notches / home indicators. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #141029;
    overscroll-behavior: none;
}

body {
    position: fixed;
    inset: 0;
    color: rgba(255, 255, 255, 0.87);
    font-family: "DotGothic16", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

/* Largest visible area: dvh follows mobile URL bars; vh is the fallback. */
#app {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: #141029;
    overflow: hidden;
}

#game-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* No "pixelated" here: the canvas is scaled by non-integer factors on most
   screens, and nearest-neighbour scaling breaks up Thai glyphs. */
canvas {
    display: block;
    touch-action: none;
}

/* In fullscreen the #app element fills the screen on its own. */
#app:fullscreen {
    width: 100%;
    height: 100%;
}

/* ---- Landscape-only prompt (see src/game/display/Display.ts) ---- */
#rotate-hint {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 50% 35%, rgba(242, 193, 78, 0.16), transparent 60%),
        #141029;
    color: #fdf6e3;
    text-align: center;
}

#rotate-hint .rotate-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 320px;
    padding: 28px 24px 24px;
    border: 4px solid #3a3350;
    border-radius: 14px;
    background: #211b36;
    box-shadow: 0 6px 0 #0c0918;
}

#rotate-hint p {
    margin: 0;
    line-height: 1.5;
}

#rotate-hint .rotate-jp {
    font-size: 22px;
}

#rotate-hint .rotate-th {
    font-size: 17px;
    color: #f2c14e;
}

#rotate-hint .rotate-note {
    font-size: 13px;
    color: #bcc3cf;
}

#rotate-hint .rotate-device {
    position: relative;
    width: 48px;
    height: 80px;
    margin: 4px 0 18px;
    border: 4px solid #fdf6e3;
    border-radius: 9px;
    animation: rotate-hint 2.4s ease-in-out infinite;
}

/* A little paw on the "screen" so the icon reads as the game. */
#rotate-hint .rotate-paw {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 12px;
    margin: -2px 0 0 -7px;
    border-radius: 50% 50% 45% 45%;
    background: #e07a2e;
    box-shadow: -8px -10px 0 -3px #e07a2e, 0 -13px 0 -3px #e07a2e, 8px -10px 0 -3px #e07a2e;
}

@keyframes rotate-hint {
    0%, 25% { transform: rotate(0deg); }
    55%, 85% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
    #rotate-hint .rotate-device {
        animation: none;
        transform: rotate(-90deg);
    }
}

/* Same query as PORTRAIT_QUERY in Display.ts (which also pauses the game). */
@media (orientation: portrait) and (pointer: coarse) {
    #rotate-hint {
        display: flex;
    }
}

/* ---- Feedback form overlay (src/game/feedback/FeedbackOverlay.ts) ---- */
.fb-overlay {
    position: absolute;
    inset: 0;
    z-index: 8; /* below #rotate-hint (10) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: rgba(20, 16, 41, 0.72);
    font-family: "DotGothic16", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
    color: #1b1726;
    -webkit-user-select: text;
    user-select: text;
    touch-action: pan-y;
}

.fb-panel {
    display: flex;
    flex-direction: column;
    width: min(760px, 100%);
    max-height: 100%;
    background: #fdf6e3;
    border: 4px solid #1b1726;
    border-radius: 10px;
    box-shadow: 0 6px 0 #0c0918;
    overflow: hidden;
}

.fb-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px 10px;
    background: #211b36;
    color: #fdf6e3;
}

.fb-heading { flex: 1; min-width: 0; }
.fb-kicker { font-size: 13px; color: #f2c14e; }
.fb-title { margin: 2px 0 0; font-size: 20px; font-weight: normal; line-height: 1.35; overflow-wrap: anywhere; }

.fb-close {
    flex: none;
    width: 44px;
    height: 44px;
    border: 3px solid #fdf6e3;
    border-radius: 8px;
    background: #2e2a57;
    color: #fdf6e3;
    font: inherit;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.fb-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 18px 18px;
    touch-action: pan-y;
}

.fb-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 16px 12px;
    border-top: 3px solid #e6dcc2;
    background: #f6ecd2;
}

.fb-status { flex: 1 1 200px; min-height: 1.4em; font-size: 15px; color: #5a6275; }
.fb-status-error { color: #b8323a; }
.fb-actions { display: flex; gap: 10px; margin-left: auto; }

.fb-btn {
    min-width: 120px;
    min-height: 48px;
    padding: 8px 18px;
    border: 3px solid #1b1726;
    border-radius: 8px;
    font: inherit;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 0 #1b1726;
}
.fb-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #1b1726; }
.fb-btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.fb-primary { background: #b8323a; color: #fdf6e3; }
.fb-secondary { background: #fdf6e3; color: #1b1726; }

.fb-desc, .fb-text-block { margin: 0 0 12px; font-size: 16px; line-height: 1.6; white-space: pre-wrap; color: #3a3350; }
.fb-section-title, .fb-heading-block { margin: 4px 0 10px; font-weight: normal; font-size: 20px; }
.fb-panel-block { margin: 0 0 12px; padding: 10px 12px; border: 2px solid #d8cba8; border-radius: 8px; background: #fffaf0; font-size: 15px; line-height: 1.55; white-space: pre-wrap; }
.fb-divider { border: 0; border-top: 2px dashed #d8cba8; margin: 12px 0; }

.fb-q { margin: 0 0 16px; padding: 10px 12px 12px; border: 2px solid transparent; border-radius: 8px; background: #fffaf0; }
.fb-q.fb-invalid { border-color: #b8323a; }
.fb-q-title { font-size: 17px; line-height: 1.5; margin-bottom: 6px; }
.fb-req { color: #b8323a; }
.fb-q-desc { margin: 0 0 8px; font-size: 14px; color: #5a6275; white-space: pre-wrap; }
.fb-error { margin-top: 6px; font-size: 14px; color: #b8323a; }

.fb-input, .fb-textarea, .fb-select {
    box-sizing: border-box;
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #1b1726;
    border-radius: 6px;
    background: #ffffff;
    color: #1b1726;
    font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
    font-size: 16px; /* ≥16px: iOS does not zoom into the field */
    -webkit-user-select: text;
    user-select: text;
}
.fb-textarea { resize: vertical; min-height: 88px; }
.fb-input:focus, .fb-textarea:focus, .fb-select:focus, .fb-btn:focus-visible, .fb-choice:focus-visible, .fb-scale-btn:focus-visible, .fb-close:focus-visible {
    outline: 3px solid #f2c14e;
    outline-offset: 2px;
}
.fb-other { margin-top: 6px; }

.fb-choices { display: flex; flex-direction: column; gap: 6px; }
.fb-choices-nested { margin: 6px 0 0 22px; }
.fb-choice {
    position: relative;
    width: 100%;
    min-height: 44px;
    padding: 8px 12px 8px 40px;
    border: 2px solid #bcb29a;
    border-radius: 8px;
    background: #ffffff;
    color: #1b1726;
    font: inherit;
    font-size: 16px;
    text-align: left;
    cursor: pointer;
}
.fb-choice::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -10px;
    border: 2px solid #1b1726;
    background: #ffffff;
}
.fb-radio::before { border-radius: 50%; }
.fb-check::before { border-radius: 3px; }
.fb-choice.fb-on { border-color: #1b1726; background: #fff2c9; }
.fb-choice.fb-on::before { background: #b8323a; box-shadow: inset 0 0 0 3px #ffffff; }

.fb-scale { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-scale-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 4px 10px;
    border: 2px solid #1b1726;
    border-radius: 8px;
    background: #ffffff;
    color: #1b1726;
    font: inherit;
    font-size: 17px;
    cursor: pointer;
}
.fb-scale-btn.fb-on { background: #f2c14e; box-shadow: inset 0 -3px 0 #c9a23a; }
.fb-matrix-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; }
.fb-matrix-label { flex: 1 1 160px; font-size: 15px; }

.fb-notice { padding: 24px 8px; text-align: center; font-size: 17px; line-height: 1.6; }
.fb-notice p { margin: 0; }
.fb-loading p::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: fb-dots 1.2s steps(4) infinite; }
.fb-problem { color: #b8323a; }
.fb-closed { color: #3a3350; }
@keyframes fb-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.fb-success { padding: 18px 8px 8px; text-align: center; }
.fb-success-jp { margin: 12px 0 4px; font-size: 24px; }
.fb-success-th { margin: 0; font-size: 17px; color: #3a3350; }
.fb-success-paw {
    width: 28px;
    height: 24px;
    margin: 0 auto;
    border-radius: 50% 50% 45% 45%;
    background: #e07a2e;
    box-shadow: -18px -20px 0 -6px #e07a2e, 0 -26px 0 -6px #e07a2e, 18px -20px 0 -6px #e07a2e;
    margin-top: 24px;
}

/* Short landscape phones: use the whole height and tighter spacing. */
@media (max-height: 480px) {
    .fb-overlay { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: max(4px, env(safe-area-inset-bottom)); }
    .fb-panel { max-height: 100%; height: 100%; }
    .fb-head { padding: 6px 12px; }
    .fb-title { font-size: 17px; }
    .fb-close { width: 40px; height: 40px; }
    .fb-body { padding: 10px 14px 12px; }
    .fb-foot { padding: 6px 12px 8px; }
    .fb-btn { min-height: 42px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .fb-loading p::after { animation: none; content: "…"; }
}
