:root {
  --fr-bg: #f0fdf4;
  --fr-surface: #ffffff;
  --fr-ink: #0f172a;
  --fr-ink-muted: #334155;
  --fr-accent: #15803d;
  --fr-accent-dark: #166534;
  --fr-border: #bbf7d0;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; color: var(--fr-ink); background: linear-gradient(160deg, #f0fdf4 0%, #dcfce7 55%, #ecfccb 100%); min-height: 100dvh; overflow-x: hidden; }

.fr-app { max-width: 1040px; margin: 0 auto; padding: 12px 16px 28px; display: flex; flex-direction: column; gap: 14px; }

.fr-topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: rgba(255,255,255,0.94); border: 1.5px solid #86efac; border-radius: 16px; padding: 10px 14px; box-shadow: 0 4px 16px rgba(21,128,61,0.08); }
.fr-topbar-left, .fr-topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fr-brand-title { margin: 0; font-size: clamp(1.05rem, 2.4vw, 1.35rem); font-weight: 800; color: var(--fr-ink); }

.fr-btn-ghost, .fr-btn-pill, .fr-btn-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 13px; border-radius: 999px; font-size: 0.92rem; font-weight: 700; text-decoration: none; cursor: pointer; border: 1.5px solid #cbd5e1; background: #ffffff; color: var(--fr-ink); transition: transform 0.14s ease, border-color 0.14s ease; }
.fr-btn-ghost:hover, .fr-btn-pill:hover, .fr-btn-action:hover { border-color: var(--fr-accent); background: #f0fdf4; transform: translateY(-1px); }
.fr-btn-share { background: #15803d; border-color: #15803d; color: #ffffff; }
.fr-btn-share:hover { background: #166534; border-color: #166534; color: #ffffff; }

.fr-lobby-card { background: var(--fr-surface); border: 1.5px solid #86efac; border-radius: 24px; padding: 20px; box-shadow: 0 12px 32px rgba(21,128,61,0.10); display: flex; flex-direction: column; gap: 20px; }
.fr-hero-heading { margin: 0 0 8px; font-size: clamp(1.35rem, 3vw, 1.85rem); font-weight: 900; color: var(--fr-ink); }

.fr-mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.fr-mode-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: 18px; border: 2px solid #cbd5e1; background: #ffffff; color: var(--fr-ink); text-align: left; cursor: pointer; transition: all 0.15s ease; }
.fr-mode-card:hover { border-color: var(--fr-accent); background: #f0fdf4; }
.fr-mode-card.is-selected { border-color: #15803d; background: #f0fdf4; box-shadow: 0 0 0 3px rgba(21,128,61,0.2); }
.fr-mode-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fr-mode-badge { padding: 4px 10px; border-radius: 999px; background: #15803d; color: #ffffff; font-size: 0.78rem; font-weight: 800; }
.fr-mode-best { font-size: 0.82rem; font-weight: 700; color: #166534; }
.fr-mode-title { font-size: 1.12rem; font-weight: 900; color: var(--fr-ink); }
.fr-mode-sub { margin: 0; font-size: 0.9rem; color: var(--fr-ink-muted); line-height: 1.45; }

.fr-lobby-footer { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.fr-btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 28px; border-radius: 16px; border: none; background: #15803d; color: #ffffff; font-size: 1.08rem; font-weight: 800; cursor: pointer; box-shadow: 0 8px 20px rgba(21,128,61,0.28); transition: transform 0.14s ease, background 0.14s ease; }
.fr-btn-primary:hover { background: #166534; transform: translateY(-2px); }
.fr-btn-secondary { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 20px; border-radius: 14px; border: 2px solid #15803d; background: #ffffff; color: #15803d; font-size: 0.98rem; font-weight: 800; cursor: pointer; }
.fr-btn-full { width: 100%; }
.fr-lobby-tip { margin: 0; font-size: 0.88rem; font-weight: 700; color: var(--fr-ink-muted); text-align: center; }

/* PLAY SCREEN */
.fr-hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #ffffff; border: 1.5px solid #86efac; border-radius: 18px; padding: 12px 16px; }
.fr-stat-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; background: #f0fdf4; border: 1.5px solid #86efac; font-size: 0.92rem; font-weight: 700; color: var(--fr-ink); }
.fr-stat-pill strong { font-size: 1.2rem; color: #15803d; }
.fr-duo-score { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; font-weight: 800; }
.fr-duo-score.fr-p1 { background: #dbeafe; color: #1e3a8a; border: 1.5px solid #93c5fd; }
.fr-duo-score.fr-p2 { background: #ffedd5; color: #9a3412; border: 1.5px solid #fdba74; }
.fr-duo-round { font-weight: 800; color: var(--fr-ink); }

.fr-stage { background: #ffffff; border: 2px solid #86efac; border-radius: 24px; padding: 22px 18px; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: 0 12px 28px rgba(21,128,61,0.10); }
.fr-command-banner { width: 100%; max-width: 460px; padding: 14px 20px; border-radius: 18px; text-align: center; display: flex; flex-direction: column; gap: 2px; transition: background 0.15s ease; }
.fr-command-banner.cmd-win { background: #1d4ed8; color: #ffffff; }
.fr-command-banner.cmd-lose { background: #dc2626; color: #ffffff; }
.fr-command-banner.cmd-draw { background: #b45309; color: #ffffff; }
.fr-command-sub { font-size: 0.82rem; font-weight: 700; opacity: 0.92; }
.fr-command-text { font-size: clamp(1.7rem, 4.5vw, 2.3rem); font-weight: 900; letter-spacing: -0.02em; }

.fr-opponent-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 32px; border-radius: 22px; background: #f0fdf4; border: 2px solid #86efac; min-width: 200px; }
.fr-opponent-hand { font-size: 4.5rem; line-height: 1.1; }
.fr-opponent-name { font-size: 1.15rem; font-weight: 900; color: var(--fr-ink); }

.fr-timer-bar-wrap { width: 100%; max-width: 460px; height: 12px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.fr-timer-bar-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #16a34a, #eab308); transition: width 0.08s linear; }

.fr-feedback { min-height: 28px; font-size: 1.02rem; font-weight: 800; color: var(--fr-ink); text-align: center; }
.fr-feedback.is-good { color: #15803d; }
.fr-feedback.is-bad { color: #b91c1c; }

.fr-controls-solo { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fr-hand-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 18px 10px; border-radius: 20px; border: 2.5px solid #86efac; background: #ffffff; color: var(--fr-ink); cursor: pointer; box-shadow: 0 6px 16px rgba(15,23,42,0.08); transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease; }
.fr-hand-btn:hover { border-color: #15803d; background: #f0fdf4; transform: translateY(-2px); }
.fr-hand-btn:active { transform: scale(0.96); }
.fr-hand-emoji { font-size: 2.8rem; line-height: 1; }
.fr-hand-btn strong { font-size: 1.15rem; font-weight: 900; }
.fr-hand-btn kbd { padding: 2px 8px; border-radius: 6px; background: #f1f5f9; border: 1px solid #cbd5e1; font-size: 0.78rem; font-weight: 700; color: #334155; font-family: inherit; }

.fr-controls-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.fr-player-pad { padding: 14px; border-radius: 20px; border: 2px solid #cbd5e1; background: #ffffff; display: flex; flex-direction: column; gap: 10px; }
.fr-pad-p1 { border-color: #60a5fa; background: #eff6ff; }
.fr-pad-p2 { border-color: #fb923c; background: #fff7ed; }
.fr-pad-label { text-align: center; font-weight: 900; font-size: 0.96rem; color: var(--fr-ink); }
.fr-pad-btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fr-hand-sm { padding: 12px 6px; }
.fr-hand-sm span { font-size: 2rem; }
.fr-hand-sm strong { font-size: 0.95rem; }

/* MODALS */
.fr-modal-card { width: 100%; max-width: 440px; background: #ffffff; border-radius: 22px; padding: 24px; box-shadow: 0 20px 50px rgba(15,23,42,0.28); color: var(--fr-ink); }
.fr-modal-card h2 { margin: 0 0 12px; font-size: 1.35rem; font-weight: 900; }
.fr-result-card, .fr-qr-card { text-align: center; }
.fr-result-badge { font-size: 3rem; margin-bottom: 6px; }
.fr-result-sub, .fr-qr-desc { margin: 0 0 18px; color: var(--fr-ink-muted); font-size: 0.98rem; line-height: 1.5; font-weight: 600; }
.fr-result-actions, .fr-qr-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.fr-help-list { margin: 0 0 18px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; line-height: 1.55; color: var(--fr-ink-muted); }
.fr-help-list strong { color: var(--fr-ink); }
.fr-qr-img { width: 220px; height: 220px; margin: 0 auto 16px; display: block; border-radius: 14px; border: 2px solid #86efac; }

@media (max-width: 780px) {
  .fr-mode-grid, .fr-controls-duo { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.fr-body { --scene-focus: #1e40af; }
.fr-play { display: grid; gap: clamp(10px, 1.1vw, 16px); }
.scene-game .fr-topbar { background: #f7fffc; border: 2px solid #fff; border-radius: 999px; }
.fr-play .fr-hud {
  background: #effffb;
  border: 3px double #22816b;
  border-radius: 999px;
  width: min(100%, 1000px);
  min-height: clamp(54px, 4.7vw, 68px);
  justify-self: center;
  padding: 4px clamp(8px, 1.2vw, 17px);
  box-shadow: 0 4px 10px #064d5f40;
}
.fr-play .fr-stat-pill { border: 0; background: transparent; padding: 4px 8px; }
.fr-play .fr-stat-pill strong { font-size: clamp(17px, 2.2vw, 32px); }
.fr-play .fr-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(7px, .9vw, 13px);
  border: 0;
  padding: clamp(22px, 2.4vw, 35px) 0 0;
  background: none;
  box-shadow: none;
  width: 78%;
  margin-left: 22%;
}
.fr-play .fr-prompt { display: grid; justify-items: center; gap: clamp(10px, 1.8vw, 26px); width: 100%; }
.fr-play .fr-command-banner {
  background: transparent;
  width: min(51%, 640px);
  min-height: clamp(92px, 11.4vw, 164px);
  padding: clamp(2px, .5vw, 8px);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
}
.fr-play .fr-command-sub {
  font-size: clamp(14px, 1.45vw, 21px);
  padding: 4px 18px;
  border-radius: 999px;
  background: #fff1bc;
  color: #612703;
}
.fr-play .fr-command-text {
  font-size: clamp(31px, 5.5vw, 79px);
  color: #fff8e8;
  line-height: 1.1;
  text-shadow: 0 3px 0 #733000, 0 0 5px #733000;
}
.fr-play .fr-opponent-card {
  min-height: clamp(88px, 13.6vw, 199px);
  width: clamp(115px, 17vw, 244px);
  padding: clamp(8px, 1vw, 14px);
  justify-content: center;
  border: 4px solid #f6fff4;
  outline: 3px solid #72e397;
  border-radius: clamp(16px, 3vw, 42px);
  box-shadow: 0 1px 17px #0d5068ad;
}
.fr-play .fr-opponent-hand { font-size: clamp(42px, 7.2vw, 104px); }
.fr-play .fr-opponent-name { font-size: clamp(18px, 2.2vw, 32px); }
.fr-play .fr-timer-bar-wrap { width: min(32%, 440px); height: 5px; }
.fr-play .fr-feedback {
  margin: 0;
  width: fit-content;
  max-width: 84%;
  min-height: 0;
  border-radius: 999px;
  padding: 8px 16px;
  background: #f7fffc;
  border: 2px solid #c4eaff;
  font-size: clamp(14px, 1.35vw, 20px);
}
.fr-play .fr-feedback.is-good { color: #0f642f; }
.fr-play .fr-feedback.is-bad { color: #981d21; }
.fr-play .fr-controls-solo { width: min(100%, 1160px); justify-self: center; gap: clamp(7px, 1vw, 15px); }
.fr-play .fr-controls-solo .fr-hand-btn {
  display: grid;
  grid-template-columns: auto auto;
  justify-items: center;
  gap: 4px 10px;
  min-height: clamp(78px, 12.2vw, 176px);
  padding: 8px 3px;
  border-radius: clamp(16px, 4vw, 55px);
  background: linear-gradient(#e2f8ff, #9adcf7);
  border: 3px solid #c6efff;
  box-shadow: inset 0 -4px 0 #02061733, 0 6px 0 #133b5a9c;
}
.fr-play .fr-controls-solo .fr-hand-btn[data-hand="rock"] {
  background: linear-gradient(#fff8c9, #ffe07d);
  border-color: #fff5ab;
}
.fr-play .fr-controls-solo .fr-hand-btn[data-hand="paper"] {
  background: linear-gradient(#fff0f6, #ffb0d2);
  border-color: #ffdef1;
}
.fr-play .fr-controls-solo .fr-hand-emoji { font-size: clamp(30px, 5.6vw, 80px); }
.fr-play .fr-controls-solo strong { font-size: clamp(18px, 3vw, 43px); }
.fr-play .fr-controls-solo kbd { grid-column: 1 / -1; border-radius: 999px; background: #fffdf1; }
.fr-hand-btn { min-width: 0; min-height: 44px; }
.fr-hand-btn:disabled { cursor: default; opacity: .8; }
.fr-play[data-mode="duo"] .fr-opponent-card { min-height: clamp(78px, 9vw, 132px); }
.fr-play[data-mode="duo"] .fr-opponent-hand { font-size: clamp(32px, 5vw, 72px); }
.fr-play .fr-controls-duo { width: min(100%, 1160px); justify-self: center; }

@media (max-aspect-ratio: 5/4), (max-width: 799px) {
  .scene-game .fr-art { object-position: 24% 50%; }
  .fr-play .fr-stage { width: 100%; margin: 0; padding: 0; }
  .fr-play .fr-command-banner {
    min-height: 82px;
    width: min(100%, 440px);
    background: #944307;
    border: 3px solid #ffca62;
    border-radius: 24px;
  }
  .fr-play .fr-timer-bar-wrap { width: min(90%, 360px); }
  .fr-play .fr-feedback { max-width: 100%; }
}
@media (max-width: 600px) {
  .scene-game .fr-topbar { border-radius: 18px; }
  .fr-play .fr-hud { padding: 5px 8px; border-radius: 18px; gap: 4px 6px; }
  .fr-play .fr-stat-pill { padding: 2px; gap: 3px; font-size: .875rem; }
  .fr-play .fr-stat-pill strong { font-size: 1rem; }
  .fr-play .fr-duo-score, .fr-play .fr-duo-round { font-size: .875rem; }
  .fr-play .fr-duo-score { padding: 5px; }
  .fr-play .fr-controls-solo .fr-hand-btn { grid-template-columns: 1fr; }
  .fr-play .fr-controls-duo { gap: 9px; }
  .fr-player-pad { padding: 6px; gap: 5px; }
  .fr-hand-sm { padding-block: 6px; }
}

.fr-body:has(#screen-play:not([hidden])) .fr-topbar { background: none; border-color: transparent; padding: 0; }
.fr-body:has(#screen-play:not([hidden])) .fr-brand-title { color: #fff; font-size: clamp(17px, 2.1vw, 30px); text-shadow: 0 2px 3px #013e4f, 0 0 9px #073940; }
.fr-play .fr-controls-solo kbd { font-size: clamp(12px, 1.25vw, 18px); }
.fr-play .fr-command-sub { background: #fff1bc; color: #612703; }
.fr-play .cmd-win .fr-command-sub { background: #e2f4ff; color: #18406d; }
.fr-play .cmd-lose .fr-command-sub { background: #ffe5df; color: #761d25; }
@media (min-width: 800px) and (min-aspect-ratio: 5/4) {
  .fr-play .fr-stage { padding-top: clamp(8px, 2vw, 25px); }
}

.fr-play .fr-hand-btn {
  isolation: isolate;
  position: relative;
  --plate-tone: none;
}
.fr-play .fr-hand-btn[data-hand="rock"] { --plate-tone: hue-rotate(204deg) saturate(1.12); }
.fr-play .fr-hand-btn[data-hand="paper"] { --plate-tone: hue-rotate(130deg) saturate(1.1); }
.fr-play .fr-hand-btn::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -2px;
  border: clamp(11px, 2.3vw, 32px) solid transparent;
  border-image: url("../images/answer-plate.1d219356f471.webp") 46 fill stretch;
  pointer-events: none;
  filter: var(--plate-tone);
}
.fr-play .fr-controls-solo .fr-hand-btn { box-shadow: none; }
.fr-play .fr-hand-btn[data-hand]:hover:not(:disabled) { filter: brightness(1.06); }

.fr-stat-label { display: inline-flex; align-items: center; gap: 6px; }
.fr-stat-icon { font-size: 1.4em; }
.fr-play .fr-controls-solo .fr-hand-btn { align-content: center; }
@media (min-width: 800px) and (min-aspect-ratio: 5/4) {
  .fr-play .fr-command-text { font-size: clamp(60px, 6.1vw, 90px); }
  .fr-stat-icon { font-size: 1.75em; }
  .fr-play .fr-stat-pill { font-size: 1.05rem; }
}
@media (max-width: 600px) { .fr-stat-icon { display: none; } }
