* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #b9d3e8;
  font-family: 'Noto Sans JP', system-ui, sans-serif;
  color: #f4f4f4;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#game, #draw { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#game { touch-action: none; }
#draw, #fx, #guide, #hud, #banner { pointer-events: none; }
#fx { position: fixed; inset: 0; overflow: hidden; }
.hidden { display: none !important; }

#guide {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 24px); text-align: center;
  font-size: 12px; font-weight: 500; padding: 5px 12px; border-radius: 4px;
  background: rgba(15, 18, 24, 0.55);
}
#guide .l { color: #6fa3ff; }
#guide .r { color: #ff6b75; }
#online-leave { position: fixed; top: 86px; right: 12px; z-index: 3; font-size: 12px; padding: 5px 10px; background: rgba(15, 18, 24, 0.75); }

/* HUD */
#hud {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  width: min(820px, calc(100% - 20px));
  display: flex; align-items: flex-start; gap: 10px;
}
#hud .side { flex: 1; }
#hud .c { text-align: right; }
#hud .name {
  font-family: 'Oswald', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
#hud .p .name { color: #8db7ff; }
#hud .c .name { color: #ff8d95; }
#hud .bar {
  position: relative; height: 16px; overflow: hidden; margin-top: 2px;
  background: rgba(15, 18, 24, 0.7); border: 2px solid rgba(255, 255, 255, 0.85);
  transform: skewX(-18deg);
}
#hud .fill, #hud .lag { position: absolute; top: 0; bottom: 0; transition: width 0.08s; }
#hud .lag { background: #f0e6c8; }
#hud .p .fill, #hud .p .lag { left: 0; }
#hud .c .fill, #hud .c .lag { right: 0; }
#hud .p .fill { background: linear-gradient(#5b9dff, #1f5fd6); }
#hud .c .fill { background: linear-gradient(#ff6070, #c8202e); }
#hud .fill.low { animation: blink 0.4s infinite alternate; }
@keyframes blink { to { filter: brightness(1.6); } }
#hud .stam {
  position: relative; height: 7px; margin-top: 3px; overflow: hidden;
  background: rgba(15, 18, 24, 0.7); border: 1px solid rgba(255, 255, 255, 0.6);
  transform: skewX(-18deg);
}
#hud .sfill { position: absolute; top: 0; bottom: 0; background: linear-gradient(#ffe36a, #f0b400); }
#hud .p .sfill { left: 0; }
#hud .c .sfill { right: 0; }
#hud .sfill.empty { background: #ff4a55; }
#hud .stam.shake { animation: stamshake 0.3s; }
@keyframes stamshake { 25% { margin-left: -4px; } 75% { margin-left: 4px; } }
#hud .stats { margin-top: 5px; font-size: 12px; font-weight: 900; display: flex; gap: 5px; }
#hud .c .stats { justify-content: flex-end; }
#hud .st { opacity: 0.3; background: rgba(15, 18, 24, 0.6); padding: 1px 7px; border-radius: 3px; }
#hud .st.on { opacity: 1; }
#timer {
  min-width: 62px; text-align: center; font-family: 'Oswald', sans-serif; font-weight: 700; font-size: 28px;
  background: rgba(15, 18, 24, 0.75); border: 2px solid rgba(255, 255, 255, 0.85); padding: 0 8px; line-height: 1.3;
}

/* ヒット文字 */
.pop {
  position: absolute; transform: translate(-50%, -50%);
  font-weight: 900; font-size: 24px; color: #fff; white-space: nowrap; font-style: italic;
  -webkit-text-stroke: 5px #111; paint-order: stroke fill;
  animation: pop 0.7s ease-out forwards;
}
.pop.big { font-size: 38px; color: #ffd23a; }
.pop.block { font-size: 20px; color: #bfe3ff; }
.pop.tangle { font-size: 26px; color: #d6b4ff; }
.pop.item { font-size: 22px; color: #9ff0b8; }
@keyframes pop {
  0% { transform: translate(-50%, -50%) scale(0.4) rotate(var(--rot)); opacity: 1; }
  20% { transform: translate(-50%, -70%) scale(1.15) rotate(var(--rot)); }
  100% { transform: translate(-50%, -150%) scale(1) rotate(var(--rot)); opacity: 0; }
}

/* バナー */
.banner {
  position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%) scale(0);
  font-family: 'Oswald', sans-serif; font-weight: 700; font-style: italic;
  font-size: clamp(52px, 13vw, 120px); color: #fff; opacity: 0; letter-spacing: 4px;
  -webkit-text-stroke: 8px #111; paint-order: stroke fill; white-space: nowrap;
}
.banner.show { animation: banner 1.2s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.banner.fight { color: #ffd23a; }
.banner.ko { color: #ff4a55; animation-duration: 2s; }
@keyframes banner {
  0% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.05); opacity: 0; }
}

/* タイトル・結果 */
.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: linear-gradient(rgba(10, 12, 18, 0.15), rgba(10, 12, 18, 0.55));
}
.card {
  background: rgba(15, 18, 24, 0.82); border-left: 6px solid #ffd23a;
  padding: 22px 26px; max-width: 580px; width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  max-height: calc(100vh - 32px); overflow: auto;
}
.card.small { max-width: 380px; text-align: center; }
#file-warning { z-index: 10; background: #192638; }
#file-warning .card { max-width: 520px; text-align: left; }
#file-warning h2 { margin-bottom: 14px; color: #ffd23a; font-size: 30px; }
#file-warning p { margin-top: 10px; line-height: 1.7; }
h1 {
  font-family: 'Oswald', sans-serif; font-style: italic; font-size: clamp(40px, 9vw, 64px);
  font-weight: 700; letter-spacing: 3px; line-height: 1; color: #fff;
}
.sub { margin: 8px 0 14px; font-weight: 900; color: #ffd23a; font-size: 14px; }
.howto { list-style: none; font-size: 14px; line-height: 1.6; margin-bottom: 18px; color: #d8dce4; }
.howto li { padding: 2px 0 2px 16px; position: relative; }
.howto li::before { content: ''; position: absolute; left: 0; top: 11px; width: 7px; height: 3px; background: #ffd23a; }
.howto b { color: #fff; }
.levels { display: flex; gap: 10px; flex-wrap: wrap; }
.card.small .levels { justify-content: center; }
button {
  font-family: inherit; font-weight: 900; font-size: 16px; color: #fff;
  background: transparent; border: 2px solid #fff; padding: 9px 22px; cursor: pointer;
  transition: transform 0.08s, background-color 0.12s, color 0.12s, border-color 0.12s;
}
button.main { background: #ffd23a; border-color: #ffd23a; color: #111; }
button:hover { transform: translateY(-2px); background: #fff; color: #15191f; }
button.main:hover { background: #fff0a3; border-color: #fff0a3; color: #111; }
.levels button:hover { background: #ffd23a; border-color: #ffd23a; color: #111; }
button:active { transform: translateY(1px); }
#online-rematch { display: none; }
#online-rematch:not(.hidden) { display: inline-block; }

.online-entry {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.2);
  color: #d8dce4; font-size: 13px; font-weight: 900;
}
.online-button { border-color: #70d6b0; color: #b5ffe2; }
.online-button:hover { background: #70d6b0; border-color: #70d6b0; color: #10251d; }
.online-card { max-width: 540px; border-left-color: #70d6b0; }
.online-kicker {
  margin-bottom: 4px; color: #8be8c1; font: 700 13px 'Oswald', sans-serif;
  letter-spacing: 2px;
}
#online-heading { font: italic 700 clamp(30px, 7vw, 42px) 'Oswald', sans-serif; letter-spacing: 1px; }
.online-intro { margin: 6px 0 15px; color: #d8dce4; font-size: 14px; }
.connection-notice {
  margin: 0 0 16px; padding: 13px 15px; color: #d8dce4;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.14);
  line-height: 1.65; font-size: 13px;
}
.connection-notice h3 { margin-bottom: 5px; color: #8be8c1; font-size: 14px; }
.connection-notice p + p { margin-top: 7px; }
.online-actions { display: flex; gap: 10px; margin-bottom: 15px; }
.online-actions button { flex: 1; }
.online-label { display: block; margin: 9px 0 5px; color: #f4f4f4; font-size: 12px; font-weight: 900; }
.online-input-row { display: flex; gap: 8px; }
.online-input-row input {
  flex: 1; min-width: 0; padding: 9px 11px; border: 2px solid rgba(255, 255, 255, 0.62);
  border-radius: 0; background: rgba(6, 9, 14, 0.72); color: #fff;
  font: 500 14px 'Noto Sans JP', system-ui, sans-serif; user-select: text; -webkit-user-select: text;
}
.online-input-row input::placeholder { color: #aeb6c5; }
.online-input-row input:focus-visible { outline: 3px solid #70d6b0; outline-offset: 2px; }
.online-input-row button { flex: 0 0 auto; padding-inline: 16px; }
.invite-row { margin-top: 8px; }
.online-status {
  min-height: 22px; margin-top: 12px; color: #b5ffe2; font-size: 13px; font-weight: 900;
}
.online-footer { display: flex; justify-content: flex-end; margin-top: 4px; }
#online-panel { z-index: 5; }
#result-title { font-family: 'Oswald', sans-serif; font-style: italic; font-size: 48px; margin-bottom: 16px; letter-spacing: 2px; }
#result-title.win { color: #ffd23a; }
#result-title.lose { color: #9aa6bd; }

@media (max-width: 520px) {
  .howto { font-size: 12.5px; }
  #timer { font-size: 22px; min-width: 48px; }
  #guide { font-size: 10.5px; }
  .online-entry { flex-wrap: wrap; }
  .online-card { padding: 18px 17px; }
  .connection-notice { padding: 10px 12px; font-size: 12px; }
  .online-actions { flex-direction: column; }
  .online-actions button { width: 100%; }
  .online-input-row { gap: 6px; }
  .online-input-row input { padding-inline: 8px; font-size: 13px; }
  .online-input-row button { padding-inline: 10px; font-size: 14px; }
}
