* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0e1013; color: #eef2f5;
  font-family: 'Russo One', 'Segoe UI', Roboto, sans-serif; user-select: none; -webkit-user-select: none;
  touch-action: none; overscroll-behavior: none;
}
.screen {
  display: none; position: fixed; inset: 0; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, #2b3138, #14171b 70%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.on { display: flex; }
h1 { margin: 0; font-size: 40px; line-height: 1.05; color: #ffd23c; text-shadow: 0 3px 0 #7a2a00, 0 0 18px rgba(255, 160, 0, .35); text-align: center; }
h2 { margin: 0 0 6px; color: #ffd23c; font-size: 20px; font-weight: normal; }
h3 { margin: 0 0 4px; color: #ffd23c; font-size: 16px; font-weight: normal; }
button {
  font: inherit; font-size: 14px; color: #fff; padding: 10px 14px; border-radius: 12px;
  background: #2f363e; border: 2px solid #5c6670; touch-action: manipulation;
}
button.main { background: #f2b418; border-color: #ffe680; color: #2a1a00; }
button:active { filter: brightness(1.25); transform: scale(.98); }
input { font: inherit; }
#name, .codein {
  width: 100%; font-size: 18px; padding: 9px 14px; border-radius: 12px; color: #fff;
  background: #0b0d10; border: 2px solid #5c6670; outline: none; user-select: text; -webkit-user-select: text;
}
#name:focus, .codein:focus { border-color: #f2b418; }
.codein { text-align: center; letter-spacing: 10px; font-size: 30px; width: 200px; }
.lbl { color: #9aa6b4; font-size: 12px; margin: 0; }
.small { color: #9aa6b4; font-size: 11px; margin: 0 0 6px; line-height: 1.4; }
.status { color: #c8d0d8; font-size: 13px; text-align: center; margin: 4px 0; min-height: 1em; line-height: 1.4; }

#loading p { color: #9aa6b4; }
#rotate {
  display: none; position: fixed; inset: 0; z-index: 100; background: #14171b; color: #fff;
  flex-direction: column; align-items: center; justify-content: center; gap: 18px; font-size: 18px; text-align: center; padding: 20px;
}
#rotate .phone { width: 44px; height: 76px; border: 4px solid #ffd23c; border-radius: 9px; animation: turn 2s ease-in-out infinite; }
@keyframes turn { 0%, 30% { transform: rotate(0) } 60%, 100% { transform: rotate(-90deg) } }
@media (orientation: portrait) { #rotate { display: flex; } }

/* menu */
.two { display: flex; gap: 28px; align-items: center; max-width: 760px; width: 100%; padding: 0 16px; }
.logo { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; }
.logo img { width: 64px; height: 64px; filter: drop-shadow(2px 3px 2px rgba(0, 0, 0, .6)); }
.col { flex: 1.1; display: flex; flex-direction: column; gap: 8px; }
.seg { display: flex; border: 2px solid #5c6670; border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; padding: 7px 4px; font-size: 13px; background: #20262c; color: #9aa6b4; }
.seg button + button { border-left: 1px solid #5c6670; }
.seg button.on { background: #f2b418; color: #2a1a00; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.box {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: min(92vw, 360px);
  max-height: 96vh; overflow-y: auto; touch-action: pan-y;
}
.box.wide { width: min(94vw, 560px); }
.box h2 { text-align: center; }
.code { font-size: 46px; letter-spacing: 12px; text-align: center; color: #fff; }
.row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #c8d0d8; }
.row input[type=range] { flex: 1; accent-color: #f2b418; }
.row input[type=checkbox] { width: 20px; height: 20px; accent-color: #2fb457; }
.list { overflow-y: auto; max-height: 62vh; display: flex; flex-direction: column; gap: 6px; touch-action: pan-y; }
.list .item { background: rgba(0, 0, 0, .3); border: 1px solid #3a434d; border-radius: 10px; padding: 8px 12px; font-size: 12px; color: #c8d0d8; line-height: 1.5; }
.list .item b { color: #ffd23c; font-weight: normal; font-size: 14px; }
#resBody { text-align: center; font-size: 14px; line-height: 1.6; color: #c8d0d8; }
#resBody b { color: #fff; font-weight: normal; }
#resBody .p1 { color: #ffd23c; } #resBody .p2 { color: #6ee08a; }

/* game */
#game { background: #0e1013; flex-direction: row; align-items: stretch; padding: 0; }
.side {
  flex: none; display: flex; flex-direction: column; gap: 10px; padding: 10px 8px; overflow: hidden;
  background: linear-gradient(180deg, #1f242b, #15191d); white-space: nowrap;
}
#lp { padding-left: max(8px, env(safe-area-inset-left)); border-right: 1px solid #333b44; }
#rp { padding-right: max(8px, env(safe-area-inset-right)); border-left: 1px solid #333b44; align-items: center; }
.hbtn { align-self: flex-start; padding: 0 12px; height: 30px; font-size: 16px; line-height: 1; border-radius: 8px; border-width: 1px; }
.pl { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pl b { font-weight: normal; font-size: 14px; line-height: 1.15; white-space: normal; overflow-wrap: anywhere; max-height: 2.3em; overflow: hidden; }
.pl span { font-size: 13px; } .pl small { font-size: 11px; color: #9aa6b4; }
.pl.p1 b, .pl.p1 span { color: #ffd23c; } .pl.p2 b, .pl.p2 span { color: #6ee08a; }
#hLevel { font-size: 13px; color: #fff; letter-spacing: 1px; }
#ecounts { display: flex; flex-direction: column; gap: 2px; }
#ecounts .ec { display: flex; align-items: center; gap: 6px; font-size: 14px; color: #dfe6ee; }
#ecounts .ec img { width: 22px; height: 22px; filter: drop-shadow(1px 1px 1px #000); }
#ecounts .ec span { min-width: 30px; }
#ecounts .ec.zero { opacity: .3; }
#ecounts .ec.boss img { width: 24px; height: 24px; margin-left: -1px; }
#bossbar { width: 100%; visibility: hidden; text-align: center; }
#bossbar b { font-weight: normal; font-size: 10px; letter-spacing: 3px; color: #ff6a5a; }
#bossbar div { height: 10px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .7); background: rgba(0, 0, 0, .6); padding: 1px; }
#bossbar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(#ff5a4a, #b3161c); width: 100%; transition: width .2s; }
#stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #0b0d10; }
#field { display: block; }

.fire {
  position: fixed; border-radius: 50%; z-index: 5; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 40% 35%, rgba(255, 110, 90, .55), rgba(200, 40, 30, .7)); border: 2px solid rgba(255, 190, 170, .95);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .5);
}
.fire svg { width: 58%; height: 58%; fill: #fff; stroke: rgba(80, 0, 0, .55); stroke-width: 3; }
.fire.down { filter: brightness(1.3); transform: scale(.94); }
.fire.sel, #joy.sel, #joy.drag { outline: 3px dashed #ffd23c; outline-offset: 6px; }
#joy {
  position: fixed; z-index: 5; border-radius: 50%; touch-action: none;
  background: radial-gradient(circle, rgba(255, 255, 255, .06), rgba(255, 255, 255, .16)); border: 2px solid rgba(255, 255, 255, .65);
}
#joy .knob {
  position: absolute; left: 30%; top: 30%; width: 40%; height: 40%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, .8), rgba(255, 255, 255, .35)); border: 2px solid rgba(255, 255, 255, .9);
}
#joy svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: rgba(255, 255, 255, .75); pointer-events: none; }

#banner {
  position: fixed; left: 0; right: 0; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 6;
}
.plate {
  min-width: 260px; padding: 12px 36px 14px; border-radius: 16px; text-align: center;
  background: linear-gradient(180deg, rgba(44, 51, 60, .96), rgba(16, 19, 23, .96));
  border: 2px solid #f2b418; box-shadow: 0 8px 28px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 255, 255, .14);
  animation: pop .35s cubic-bezier(.2, 1.4, .4, 1);
}
.plate small { display: block; font-size: 13px; letter-spacing: 5px; color: #9aa6b4; }
.plate strong { display: block; font-size: 32px; font-weight: normal; letter-spacing: 2px; color: #ffd23c; text-shadow: 0 2px 0 rgba(0, 0, 0, .6); }
.plate.red { border-color: #ff4a3a; } .plate.red strong { color: #ff5a4a; }
.plate.green { border-color: #3cd070; } .plate.green strong { color: #6ee08a; }
#banner .plate.red:only-child { animation: pop .35s cubic-bezier(.2, 1.4, .4, 1), pulse 1s ease-in-out .35s infinite; }
@keyframes pop { from { transform: scale(.6); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes pulse { 50% { box-shadow: 0 8px 28px rgba(0, 0, 0, .65), 0 0 24px rgba(255, 74, 58, .55) } }

.overlay { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); }
.overlay.on { display: flex; }
.panel { background: rgba(16, 19, 23, .95); border: 2px solid #5c6670; border-radius: 16px; padding: 14px 18px; }
#help { display: none; background: rgba(0, 0, 0, .45); }
#help.on { display: block; }
#help .helptext { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, .8); padding: 10px 16px; border-radius: 12px; text-align: center; font-size: 13px; line-height: 1.6; }
#editor { position: fixed; z-index: 21; left: 50%; top: 40px; transform: translateX(-50%); width: min(380px, 52vw); display: none; flex-direction: column; gap: 6px; }
#editor.on { display: flex; }
#editor .btns { display: flex; gap: 8px; } #editor .btns button { flex: 1; }
#editor .row span { width: 42px; text-align: right; color: #fff; }

#toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50; max-width: 90vw;
  background: rgba(0, 0, 0, .85); border: 1px solid #f2b418; border-radius: 10px; padding: 8px 14px; font-size: 13px; display: none; text-align: center;
}
#toast.on { display: block; }
