:root {
  --ink: #293748;
  --paper: #fffdf2;
  --blue: #389be6;
  --coral: #ff6855;
  --yellow: #ffdc65;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--ink);
  font-family: "Outfit", "Zen Maru Gothic", "Noto Sans KR", sans-serif;
  background:
    radial-gradient(ellipse at 10% 10%, #effcff 0, transparent 45%),
    repeating-linear-gradient(135deg, #a0dfed 0 70px, #a9e4ef 70px 140px);
  min-height: 100vh;
}
button,
select,
a {
  -webkit-tap-highlight-color: transparent;
}
button,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 3px solid var(--ink);
  border-radius: 15px;
  background: white;
  font-weight: 900;
  min-height: 44px;
  box-shadow: 0 4px 0 var(--ink);
  touch-action: manipulation;
}
button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}
button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid #e25719;
  outline-offset: 3px;
}
main {
  max-width: 620px;
  margin: 0 auto;
  padding: 18px 14px 30px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 17px;
}
header a {
  font-size: 12px;
  font-weight: 900;
  color: inherit;
  text-decoration: none;
}
header div {
  display: flex;
  gap: 6px;
}
header button {
  font-size: 10px;
  padding: 4px 9px;
  min-height: 36px;
}
select {
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: white;
  max-width: 87px;
  font-size: 11px;
}
.main-card {
  padding: 24px;
  border: 4px solid var(--ink);
  border-radius: 34px;
  background: var(--paper);
  box-shadow: 0 10px 0 var(--ink);
}
.brand {
  text-align: center;
  margin: 0 0 18px;
}
.brand > span {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
}
.brand h1 {
  font-size: clamp(32px, 8vw, 50px);
  margin: 3px 0;
  text-shadow: 0 3px 0 #ffdc65;
  letter-spacing: -2px;
}
.brand p {
  font-size: 13px;
  margin: 4px 0;
}
.cover {
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: radial-gradient(circle at 50% 55%, #fff7c0, #ffb944 75%);
  isolation: isolate;
}
.cover-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.level-picker { display:flex; justify-content:space-between; align-items:center; gap:12px; margin:16px 0; font-weight:900; }
.level-picker select { max-width:none; min-height:44px; padding:8px 16px; font-size:16px; background:#fff2b4; }
body.playing { overflow:hidden; overscroll-behavior:none; }
body.playing main {
  position:fixed; inset:0; width:100%; height:100dvh; max-width:620px;
  padding: max(5px,env(safe-area-inset-top)) 8px max(5px,env(safe-area-inset-bottom));
  display:flex; flex-direction:column; gap:6px;
  --bh:min(calc(100dvh - 254px - env(safe-area-inset-top) - env(safe-area-inset-bottom)),calc((100vw - 75px) * 1.22),580px);
}
body.playing header {margin:0;flex-shrink:0;}
body.playing .main-card {padding:10px; border-radius:22px; flex:1; min-height:0; box-shadow:0 4px 0 var(--ink);}
body.playing .brand {display:none;}
body.playing details,body.playing footer,body.playing #battle>.note {display:none;}
body.playing .matchbar {margin-bottom:8px; padding:7px 10px;}
body.playing .matchbar [data-cpu-name] {font-size:11px;}
body.playing .arena {height:calc(var(--bh) + 22px); grid-template-columns:calc(var(--bh) / 2) calc(var(--bh) * .29); justify-content:center; gap:10px;}
body.playing .player-panel>canvas {height:var(--bh);width:100%;}
body.playing .arena aside {height:100%;min-height:0;display:flex;flex-direction:column;gap:5px;}
body.playing .next {height:55px;flex-shrink:0;margin:0;justify-content:center;}
body.playing .next canvas {width:38px;height:46px;}
body.playing .enemy-panel {flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;}
body.playing .enemy-panel .board-label {width:100%;flex-shrink:0;}
body.playing .enemy-panel canvas {height:calc(100% - 22px);width:auto;max-width:100%;object-fit:contain;}
body.playing .enemy-status {font-size:9px;line-height:1.2;min-height:0;margin:0;}
body.playing .controls {margin-top:10px;gap:7px;}
body.playing .controls button {min-height:44px;height:44px;font-size:24px;}
body.playing .controls .drop {font-size:14px;}
@media (orientation:landscape) and (max-height:600px) {
  body.playing main {max-width:900px;--bh:calc(100dvh - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom));}
  body.playing #battle {display:grid;grid-template-columns:1fr 180px;column-gap:14px;}
  body.playing .matchbar {grid-column:1/-1;}
  body.playing .controls {align-content:center;margin:0;grid-template-columns:repeat(2,1fr);}
  body.playing .next {height:38px;}
  body.playing .next canvas {height:30px;width:25px;}
}
.burst {
  position: absolute;
  inset: -60%;
  background: repeating-conic-gradient(
    from 0deg,
    #fff6 0 12deg,
    transparent 12deg 30deg
  );
  transform: rotate(12deg);
}
.cover > strong {
  position: absolute;
  left: 6%;
  top: 8%;
  z-index: 2;
  font-size: clamp(38px, 10vw, 68px);
  font-weight: 900;
  line-height: 0.9;
  transform: rotate(-8deg);
  color: white;
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 3px 5px var(--ink);
}
.cover em {
  font-style: normal;
  color: #ff684c;
  font-size: 0.7em;
}
.hero-rock {
  position: absolute;
  width: 38%;
  height: 37%;
  border: 5px solid var(--ink);
  border-radius: 24% 35% 22% 30%;
  box-shadow:
    inset 8px 9px #fff8,
    inset -10px -13px #0002,
    5px 10px #29374833;
  transform: rotate(-14deg);
  background: var(--coral);
  bottom: 13%;
  left: 7%;
}
.hero-rock.blue {
  background: #46b9f7;
  left: 51%;
  bottom: 20%;
  transform: rotate(18deg);
}
.hero-rock.gold {
  background: #c59beb;
  width: 23%;
  height: 22%;
  left: 48%;
  bottom: 3%;
  transform: rotate(4deg);
}
.hero-rock i:before,
.hero-rock i:after {
  content: "";
  position: absolute;
  top: 40%;
  width: 13%;
  height: 17%;
  border-radius: 4px;
  background: var(--ink);
  border-top: 5px solid white;
}
.hero-rock i:before {
  left: 24%;
  transform: rotate(-16deg);
}
.hero-rock i:after {
  right: 24%;
  transform: rotate(16deg);
}
.hero-rock b {
  position: absolute;
  left: 37%;
  top: 69%;
  width: 27%;
  border-top: 4px solid var(--ink);
  transform: rotate(-8deg);
}
.sticker {
  position: absolute;
  right: 4%;
  top: 7%;
  border: 3px solid var(--ink);
  border-radius: 50%;
  padding: 15px 7px;
  background: #fff8d5;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  transform: rotate(12deg);
}
.features {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  margin: 19px 0;
  font-size: 12px;
  font-weight: 900;
}
.primary {
  width: 100%;
  background: var(--coral);
  font-size: 23px;
  padding: 13px;
}
.note {
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
  color: #626b75;
  margin: 14px 0;
}
details {
  border-top: 2px dashed #ced0c9;
  margin-top: 20px;
  padding-top: 16px;
  font-size: 13px;
}
summary {
  font-weight: 900;
  cursor: pointer;
}
details p {
  line-height: 1.9;
}
footer {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  margin-top: 28px;
  letter-spacing: 2px;
}
[hidden] {
  display: none !important;
}
.matchbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--ink);
  color: white;
  border-radius: 14px;
  padding: 10px 13px;
  margin-bottom: 12px;
  font-size: 11px;
}
.matchbar b {
  display: flex;
  gap: 8px;
  align-items: center;
}
.matchbar b span {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.versus {
  color: var(--yellow);
  font-size: 18px;
  font-weight: 900;
}
.arena {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.58fr);
  gap: 12px;
  position: relative;
}
.player-panel,
.enemy-panel {
  position: relative;
  min-width: 0;
}
.board-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 6px;
}
.board-label span {
  min-width: 28px;
  border-radius: 20px;
  background: #e4e9ed;
  text-align: center;
  padding: 2px 5px;
  font-weight: 900;
}
.board-label span.danger {
  background: var(--coral);
  color: white;
}
canvas {
  display: block;
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #273b52;
  aspect-ratio: 1/2;
}
.next {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #e7f1ee;
  border: 2px solid var(--ink);
  border-radius: 12px;
  margin-bottom: 10px;
  padding: 5px;
}
.next small {
  font-size: 10px;
  font-weight: 900;
  writing-mode: vertical-rl;
}
.next canvas {
  border: 0;
  background: transparent;
  width: min(calc(100% - 20px), 80px);
  aspect-ratio: 5/6;
  height: auto;
  max-height: none;
}
.enemy-status {
  font-size: 10px;
  text-align: center;
  min-height: 27px;
  margin: 8px 0;
}
aside > button {
  width: 100%;
  font-size: 11px;
}
.controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
  user-select: none;
  touch-action: none;
}
.controls button {
  font-size: 27px;
  background: #e2f3ff;
  min-height: 50px;
  touch-action: none;
}
.controls button:first-child,
.controls button:nth-child(4) {
  background: var(--yellow);
}
.controls .drop {
  grid-column: 1/-1;
  font-size: 16px;
  min-height: 44px;
  background: #a8dfaa;
}
.overlay {
  position: absolute;
  inset: 0;
  background: #21364bdd;
  border: 3px solid var(--ink);
  border-radius: 14px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  gap: 14px;
  text-align: center;
  color: white;
}
.overlay > strong {
  font-size: clamp(35px, 8vw, 58px);
  font-weight: 900;
  color: var(--yellow);
  text-shadow: 0 5px #172637;
}
.overlay p {
  margin: 0;
  font-size: 13px;
}
.overlay button {
  padding: 7px 25px;
  color: var(--ink);
  background: var(--yellow);
}
.overlay a {
  color: white;
  font-size: 13px;
}
.chain-pop {
  position: absolute;
  top: 35%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(20px, 5vw, 34px);
  font-weight: 900;
  color: #ffeb7d;
  text-shadow: 2px 3px var(--ink);
  pointer-events: none;
}
.chain-pop.pop {
  animation: pop 0.65s both;
}
.enemy-panel .chain-pop {
  font-size: 18px;
}
@keyframes pop {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }
  25% {
    transform: scale(1.3);
    opacity: 1;
  }
  70% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-25px);
    opacity: 0;
  }
}
body.playing .brand {
  margin-bottom: 12px;
}
body.playing .brand > span,
body.playing .brand p {
  display: none;
}
body.playing .brand h1 {
  font-size: 27px;
}
@media (max-width: 400px) {
  main {
    padding: 12px 9px 24px;
  }
  .main-card {
    padding: 15px;
    border-radius: 26px;
  }
  .arena {
    gap: 9px;
  }
  .features {
    font-size: 10px;
  }
  .matchbar {
    padding: 8px;
  }
  .matchbar b span {
    font-size: 17px;
  }
  .controls {
    gap: 7px;
  }
  .next canvas {
    width: min(calc(100% - 20px), 62px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .chain-pop.pop {
    animation: none;
    opacity: 1;
  }
}
