@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,600;0,700;0,800;0,900;1,800&family=Nunito:wght@600;700;800;900&display=swap');

:root {
  --navy: #102641;
  --deep: #071725;
  --ice: #dff7fa;
  --blue: #176b87;
  --orange: #ff7b45;
  --yellow: #ffd166;
  --paper: #f8fffe;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--navy);
  background:
    radial-gradient(circle at 50% -20%, #38799a 0, transparent 50%),
    linear-gradient(160deg, #153c5d, #071725 72%);
  user-select: none;
  -webkit-user-select: none;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
.app { height: 100dvh; display: grid; grid-template-rows: auto 1fr; padding: 12px; gap: 10px; }
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: min(1100px, 100%); margin: auto; color: white; }
.brand { display: flex; align-items: center; gap: 8px; color: white; text-decoration: none; font-family: "Barlow Condensed", sans-serif; font-size: 24px; font-weight: 900; letter-spacing: .03em; }
.brand img { width: 35px; height: 35px; }
.brand b { color: var(--yellow); }
.run-stats { display: flex; align-items: center; gap: 9px; }
.run-stats span { display: flex; align-items: center; gap: 6px; min-height: 34px; padding: 5px 12px; border: 1px solid #ffffff26; border-radius: 99px; background: #061a2aa8; font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 13px; letter-spacing: .11em; }
.run-stats b { font-size: 18px; color: var(--yellow); }
.run-stats img { width: 18px; }
.top-actions { justify-self: end; display: flex; gap: 6px; }
.icon-button, .close-button { border: 1px solid #ffffff2e; color: white; background: #061a2aa8; border-radius: 10px; cursor: pointer; font-family: "Barlow Condensed", sans-serif; font-weight: 800; font-size: 13px; letter-spacing: .06em; min-height: 36px; padding: 0 11px; }
.icon-button:hover { background: #1e5576; }
.icon-button.square { width: 38px; padding: 0; font-size: 20px; }
.game-shell { position: relative; width: min(1100px, 100%); height: 100%; min-height: 0; margin: auto; overflow: hidden; border: 4px solid #acdbe1; border-radius: 26px; background: var(--ice); box-shadow: 0 18px 55px #0008, inset 0 0 0 2px #fff; touch-action: none; }
#game { width: 100%; height: 100%; display: block; touch-action: none; }
.turn-chip { position: absolute; z-index: 4; top: 12px; left: 50%; transform: translateX(-50%); padding: 7px 17px; border-radius: 99px; color: white; background: #10334bcc; backdrop-filter: blur(6px); box-shadow: 0 4px 0 #07213144; font-family: "Barlow Condensed", sans-serif; font-size: 14px; font-weight: 900; letter-spacing: .13em; transition: .2s ease; }
.turn-chip.enemy { background: #a83547e8; animation: pulse .65s ease 2; }
.turn-chip.wait { opacity: .72; }
.concede-button { position: absolute; z-index: 5; top: 53px; right: 12px; min-height: 31px; padding: 0 11px; border: 1px solid #93465a55; border-radius: 9px; color: #8b344b; background: #fff8f5c9; font-family: "Barlow Condensed", sans-serif; font-size: 11px; font-weight: 900; letter-spacing: .09em; cursor: pointer; backdrop-filter: blur(4px); }
.concede-button:hover, .concede-button.confirm { color: white; background: #a83547; }
.concede-button.hidden { display: none; }
.tutorial { position: absolute; z-index: 3; left: 50%; top: 22%; transform: translate(-50%, -50%); color: #174e67; text-align: center; pointer-events: none; animation: float 1.25s ease-in-out infinite; text-shadow: 0 2px white; }
.tutorial b { display: block; font-family: "Barlow Condensed", sans-serif; font-size: clamp(26px, 4vw, 44px); font-weight: 900; letter-spacing: .06em; }
.tutorial span { font-size: 12px; text-transform: uppercase; letter-spacing: .13em; }
.tutorial.hidden { display: none; }
.toast { position: absolute; z-index: 8; top: 52px; left: 50%; transform: translate(-50%, -8px); opacity: 0; padding: 7px 14px; border-radius: 8px; color: white; background: #102641e8; font-size: 12px; font-weight: 900; letter-spacing: .06em; pointer-events: none; transition: .22s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.party-hud { position: absolute; z-index: 4; bottom: 10px; left: 50%; display: flex; justify-content: center; gap: 7px; transform: translateX(-50%); pointer-events: none; }
.party-pill { display: grid; grid-template-columns: 30px auto; grid-template-rows: auto auto; column-gap: 6px; align-items: center; min-width: 106px; padding: 5px 9px 5px 6px; border: 1px solid #8cc8d2; border-radius: 13px; background: #f8ffffe8; box-shadow: 0 3px 8px #174e6733; }
.party-pill.ko { opacity: .48; filter: grayscale(.7); }
.party-pill img { grid-row: 1 / 3; width: 30px; height: 30px; }
.party-pill strong { font-family: "Barlow Condensed", sans-serif; font-size: 13px; line-height: 1; text-transform: uppercase; }
.party-pill small { font-size: 10px; white-space: nowrap; color: #517182; }
.overlay { position: absolute; z-index: 15; inset: 0; display: grid; place-items: center; padding: 18px; background: #0b294080; backdrop-filter: blur(5px); transition: opacity .2s; }
.overlay.hidden { display: none; }
.start-card, .result-card { width: min(440px, 100%); padding: 26px; border: 3px solid white; border-radius: 25px; background: #f8ffff; text-align: center; box-shadow: 0 18px 45px #06172580, 0 6px 0 #80c6cf; }
.hero-mark { width: 102px; height: 102px; margin: -77px auto 6px; filter: drop-shadow(0 8px 5px #0b294044); }
.eyebrow { margin: 0 0 4px; color: #28819c; font-family: "Barlow Condensed", sans-serif; font-size: 13px; font-weight: 900; letter-spacing: .19em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: "Barlow Condensed", sans-serif; font-weight: 900; text-transform: uppercase; line-height: .93; }
.start-card h1, .result-card h1 { font-size: clamp(45px, 8vw, 70px); letter-spacing: -.02em; }
h1 em { color: var(--orange); font-style: italic; }
.start-card > p:not(.eyebrow) { max-width: 355px; margin: 14px auto; color: #496678; font-size: 14px; line-height: 1.55; }
.gesture-demo { display: flex; align-items: center; justify-content: center; gap: 11px; height: 52px; margin: 8px 0 14px; color: #2d7188; font-family: "Barlow Condensed", sans-serif; font-weight: 900; letter-spacing: .08em; }
.gesture-demo i { width: 32px; height: 32px; border: 5px solid #183b56; border-radius: 50%; box-shadow: -28px 0 0 -11px var(--orange); animation: tug 1.2s ease-in-out infinite; }
.gesture-demo b { color: var(--orange); font-size: 25px; }
.primary-button, .secondary-button { min-height: 48px; border: 0; border-radius: 13px; padding: 0 22px; cursor: pointer; font-family: "Barlow Condensed", sans-serif; font-size: 18px; font-weight: 900; letter-spacing: .08em; }
.primary-button { color: white; background: var(--orange); box-shadow: 0 5px 0 #c64c2e; }
.primary-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #c64c2e; }
.secondary-button { color: #174e67; background: #dceff1; box-shadow: 0 5px 0 #a8ced3; }
.button-row { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.result-card #result-detail { font-size: 18px; font-weight: 900; color: #397387; }
.result-card.clear h1 { color: #e55f35; }
.result-card.defeat h1 { color: #a42f48; }
.drawer { position: fixed; z-index: 30; top: 0; right: 0; width: min(440px, 100%); height: 100dvh; padding: 22px; overflow-y: auto; color: var(--navy); background: #f7ffff; box-shadow: -18px 0 50px #0007; transform: translateX(105%); transition: transform .25s ease; }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { font-size: 43px; }
.close-button { width: 42px; height: 42px; padding: 0; border-color: #badbe0; color: #274e63; background: #e2f2f3; font-size: 28px; }
.drawer-copy { color: #5a7480; font-size: 13px; line-height: 1.5; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 15px 0; }
.slot { min-width: 0; padding: 7px 5px; border: 2px dashed #9ccbd0; border-radius: 13px; background: #eaf7f7; text-align: center; color: #52727d; }
.slot img { display: block; width: 42px; height: 42px; margin: auto; }
.slot b { display: block; overflow: hidden; font-family: "Barlow Condensed", sans-serif; font-size: 13px; text-overflow: ellipsis; text-transform: uppercase; }
.slot.locked { opacity: .48; }
.fighter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 18px; }
.fighter-card { position: relative; display: grid; grid-template-columns: 58px 1fr; align-items: center; min-height: 82px; padding: 8px; border: 2px solid #c6e2e4; border-radius: 14px; color: var(--navy); background: white; text-align: left; cursor: pointer; }
.fighter-card:hover { border-color: #4f9daf; transform: translateY(-1px); }
.fighter-card.equipped { border-color: #ff945e; box-shadow: inset 0 0 0 2px #ffe0ce; }
.fighter-card.locked { background: #eef5f5; }
.fighter-card img { width: 52px; height: 52px; }
.fighter-card strong { display: block; font-family: "Barlow Condensed", sans-serif; font-size: 19px; text-transform: uppercase; }
.fighter-card small { display: block; color: #64808b; font-size: 10px; line-height: 1.3; }
.fighter-card .price { color: #b05e18; font-size: 11px; font-weight: 900; }
.drawer > .primary-button { width: 100%; margin-bottom: 15px; }
.scrim { position: fixed; z-index: 29; inset: 0; background: #06131a9e; }
.scrim.hidden { display: none; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.08); } }
@keyframes float { 50% { transform: translate(-50%, -57%); } }
@keyframes tug { 50% { transform: translateX(-8px); } }

@media (max-width: 650px) {
  .app { padding: 7px; gap: 6px; }
  .topbar { grid-template-columns: auto 1fr auto; }
  .brand span { display: none; }
  .brand img { width: 32px; }
  .run-stats { justify-self: center; gap: 4px; }
  .run-stats span { padding: 4px 8px; font-size: 10px; }
  .run-stats b { font-size: 15px; }
  .top-actions { gap: 3px; }
  .icon-button { min-height: 33px; padding: 0 7px; font-size: 10px; }
  .icon-button.square { width: 33px; }
  .game-shell { border-width: 3px; border-radius: 19px; }
  .party-pill { min-width: 83px; grid-template-columns: 25px auto; padding: 4px 6px; }
  .party-pill img { width: 25px; height: 25px; }
  .party-pill strong { font-size: 11px; }
  .party-pill small { font-size: 8px; }
  .party-hud { width: calc(100% - 16px); flex-wrap: wrap; gap: 4px; }
  .party-pill { flex: 0 1 calc(33.333% - 4px); }
  .start-card { padding: 22px 18px; }
}

@media (max-height: 570px) {
  .hero-mark { width: 72px; height: 72px; margin-top: -56px; }
  .start-card h1 { font-size: 42px; }
  .start-card > p:not(.eyebrow) { margin: 8px auto; }
  .gesture-demo { height: 38px; margin: 3px 0 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
