:root {
  --bg: #0d1117;
  --fg: #f0f6fc;
  --accent: #2ea043;
  --surface: #161b22;
  --font-stack: "Pretendard", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --board-light: #d9d7ce;
  --board-dark: #4b5563;
  --board-line: rgba(255, 255, 255, 0.15);
  --highlight: rgba(46, 160, 67, 0.35);
  --danger: #ff7b54;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100vw;
  height: 100vh;
}

body {
  margin: 0;
  width: 100vw;
  height: 100vh;
  font-family: var(--font-stack);
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  white-space: nowrap;
}

body * {
  white-space: nowrap;
}
#app {
  width: 100vw;
  height: 100vh;
  padding: 1.5rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

.game-shell {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1 1 auto;
  min-height: 0;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.settings-button {
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  font-size: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.8);
  color: var(--fg);
  cursor: pointer;
  transition: box-shadow 0.15s ease;
  white-space: nowrap;
}

.settings-button:hover,
.settings-button:focus-visible {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.turn-panel {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.network-panel {
  padding: 1rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.network-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.network-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: rgba(240, 246, 252, 0.8);
  min-width: 140px;
  gap: 0.35rem;
}

.network-form input {
  padding: 0.45rem 0.65rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.8);
  color: var(--fg);
}

.network-form button {
  padding: 0.6rem 1.25rem;
  border-radius: 0.6rem;
  border: none;
  background: var(--accent);
  color: #0c1116;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
  white-space: nowrap;
}

.network-form button:hover,
.network-form button:focus-visible {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.move-log-panel {
  padding: 1rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

.move-log-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.move-log-header h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.move-log-hint {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(248, 250, 252, 0.55);
}

.move-log-list {
  list-style: none;
  counter-reset: moveLog;
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 260px;
  overflow-y: auto;
}

.move-log-entry {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: rgba(248, 250, 252, 0.9);
  counter-increment: moveLog;
  align-items: center;
}

.move-log-entry::before {
  content: counter(moveLog) ".";
  color: rgba(248, 250, 252, 0.5);
  font-weight: 600;
}

.move-log-entry__actor {
  font-weight: 600;
  color: rgba(248, 250, 252, 0.8);
}

.move-log-entry__text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.move-log-entry--empty {
  grid-template-columns: auto 1fr;
  counter-increment: none;
  color: rgba(248, 250, 252, 0.45);
  font-size: 0.8rem;
}

.move-log-entry--empty::before {
  content: "–";
  color: rgba(248, 250, 252, 0.3);
}

.move-log-entry--skill .move-log-entry__text {
  color: #fbbf24;
}

.move-log-entry--move .move-log-entry__text {
  color: #60a5fa;
}

button {
  white-space: nowrap;
}

.network-status {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(248, 250, 252, 0.65);
}

.play-layout {
  flex: 1 1 auto;
  display: flex;
  gap: 1.5rem;
  align-items: stretch;
  min-height: 0;
  flex-wrap: nowrap;
  overflow: visible;
}

.side-panel {
  flex: 0 0 320px;
  max-width: 340px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.side-panel--chat {
  padding-right: 0;
  overflow: hidden;
}

.side-panel--controls {
  padding-right: 0;
}

.chat-panel {
  flex: 1 1 auto;
  min-width: 0;
  background: rgba(12, 15, 20, 0.7);
  border-radius: 0.75rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
}
.chat-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.chat-panel h2 {
  margin: 0;
  font-size: 1.1rem;
}

.chat-availability {
  font-size: 0.8rem;
  color: rgba(248, 250, 252, 0.6);
}

.chat-log {
  height: 30vh;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.5rem 3.2rem;
  padding-bottom: 5rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
  line-height: 1.3;
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  background: rgba(31, 41, 55, 0.85);
}

.chat-message--self {
  background: rgba(46, 160, 67, 0.18);
  align-self: flex-end;
}

.chat-message--system {
  background: rgba(148, 163, 184, 0.15);
  color: rgba(248, 250, 252, 0.7);
  font-size: 0.78rem;
  align-self: center;
}

.chat-message__meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: rgba(248, 250, 252, 0.65);
}

.chat-message__text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-form {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  background: rgba(8, 13, 23, 0.92);
  border-radius: 0.65rem;
  padding: 0.4rem 0.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
}

.chat-form input {
  flex: 1;
  padding: 0.5rem 0.65rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.8);
  color: var(--fg);
}

.chat-form button {
  padding: 0.5rem 0.85rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--accent);
  color: #0c1116;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chat-form button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-typing {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(248, 250, 252, 0.7);
  position: absolute;
  left: 1rem;
  bottom: 3.5rem;
}

.rules-section {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.rules-section h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.rules-section ul {
  margin: 0;
  padding-left: 1.2rem;
  color: rgba(248, 250, 252, 0.85);
}

.rules-icon {
  font-size: 1.2rem;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.rules-grid article {
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.2);
  min-height: 110px;
}

.rules-grid h4 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.rules-grid p {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(248, 250, 252, 0.85);
}

.rules-footer {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: rgba(248, 250, 252, 0.75);
  text-align: right;
}

.modal-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.modal-card__eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(248, 250, 252, 0.6);
}

.modal-close {
  border: none;
  background: rgba(148, 163, 184, 0.2);
  color: var(--fg);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.turn-label {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.turn-hint {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(240, 246, 252, 0.7);
}

.label {
  margin: 0;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: rgba(240, 246, 252, 0.75);
}

h1 {
  margin: 0.25rem 0 0;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
}

.board-wrapper {
  --board-size: clamp(360px, min(82vh, calc(100vw - 320px)), 924px);
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2.5rem 2rem 2rem;
}

.board-stage {
  position: relative;
  width: var(--board-size);
  aspect-ratio: 1 / 1;
  transition: transform 0.4s ease;
  transform-origin: center;
  z-index: 5;
}

.board-turn-panel {
  position: absolute;
  top: -3.4rem;
  left: 0;
  padding: 0.55rem 0.85rem;
  border-radius: 0.6rem;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.drawer-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  color: var(--fg);
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  display: none;
  z-index: 9;
  white-space: nowrap;
}

.drawer-toggle--chat {
  left: -8rem;
  white-space: nowrap;
}

.drawer-toggle--controls {
  right: -8rem;
  white-space: nowrap;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 800;
}

.drawer-overlay[hidden] {
  display: none;
}

.board-stage--rotated {
  transform: rotate(180deg);
}

.board-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border-radius: 0.2rem;
  width: 100%;
  height: 100%;
  background: var(--board-line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.board-cell {
  background: var(--board-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  font-weight: 600;
  border-radius: 0.2rem;
  position: relative;
  transition: transform 0.12s ease;
  overflow: hidden;
}

.board-cell--dark {
  background: var(--board-dark);
  color: var(--fg);
}

.board-cell::after {
  content: attr(data-pos);
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.7);
}

.board-cell:hover {
  transform: translateY(-3px);
}

.board-cell--highlight {
  cursor: pointer;
}

.board-cell--highlight::before,
.board-cell--origin::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 0.35rem;
  border: 2px solid var(--highlight);
  background: rgba(46, 160, 67, 0.12);
  pointer-events: none;
}

.board-cell--origin::before {
  border-color: var(--accent);
  background: rgba(46, 160, 67, 0.18);
}

.board-cell--skill::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 0.35rem;
  border: 2px dashed rgba(250, 204, 21, 0.9);
  background: rgba(250, 204, 21, 0.15);
  pointer-events: none;
}

.board-coords {
  position: absolute;
  font-size: 0.75rem;
  color: rgba(240, 246, 252, 0.65);
  display: grid;
  pointer-events: none;
  gap: 2px;
  z-index: 7;
}

.board-coords--top {
  top: calc(50% - var(--board-size) / 2 - 0.9rem);
  left: 50%;
  transform: translateX(-50%);
  grid-template-columns: repeat(11, 1fr);
  text-align: center;
  width: var(--board-size);
}

.board-coords--left {
  left: calc(50% - var(--board-size) / 2 - 2.5rem);
  top: 50%;
  transform: translateY(-50%);
  grid-template-rows: repeat(11, 1fr);
  align-items: center;
  height: var(--board-size);
}

.board-coords span {
  opacity: 0.8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pieces-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}

.remote-pointer {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--pointer-accent, #7dd3fc);
  background: rgba(8, 145, 178, 0.25);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 8;
}

.remote-pointer[data-visible="true"] {
  opacity: 1;
}

.remote-pointer::after {
  content: attr(data-label);
  position: absolute;
  top: -1.2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: rgba(248, 250, 252, 0.85);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.piece {
  --piece-size: 48px;
  --action-offset: 42px;
  --piece-primary: #1f232d;
  --piece-secondary: #343a48;
  --piece-ring: rgba(255, 255, 255, 0.18);
  --piece-glyph-color: #f8fafc;
  --piece-icon: none;
  position: absolute;
  width: var(--piece-size);
  height: var(--piece-size);
  border-radius: 1rem;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.08), transparent 35%),
    linear-gradient(155deg, var(--piece-primary), var(--piece-secondary));
  color: var(--fg);
  border: 2px solid var(--piece-ring);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), inset 0 0 18px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  pointer-events: auto;
  cursor: pointer;
  padding: 0.35rem 0.4rem 0.45rem;
  transition: transform 0.25s ease, box-shadow 0.2s ease, border 0.2s ease;
  transform: translate(-9999px, -9999px);
  z-index: 1;
  isolation: isolate;
  overflow: visible;
}

.piece--hit {
  animation: piece-hit 0.38s ease;
}

@keyframes piece-hit {
  0% {
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), inset 0 0 18px rgba(0, 0, 0, 0.45);
    filter: none;
  }
  35% {
    box-shadow: 0 0 25px rgba(248, 113, 113, 0.9), inset 0 0 30px rgba(248, 113, 113, 0.65);
    filter: saturate(1.2);
  }
  100% {
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), inset 0 0 18px rgba(0, 0, 0, 0.45);
    filter: none;
  }
}

.piece--alt {
  filter: brightness(1.05);
}

.piece::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 3px solid var(--team-accent, rgba(255, 255, 255, 0.25));
  opacity: 0.5;
  pointer-events: none;
}

.piece__avatar {
  width: calc(var(--piece-size) * 0.74);
  height: calc(var(--piece-size) * 0.74);
  border-radius: 1rem;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.08), transparent 45%),
    linear-gradient(145deg, var(--piece-primary), var(--piece-secondary));
  border: 2px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.45);
}

.piece__avatar-glow {
  position: absolute;
  inset: 10%;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0.5;
}

.piece__glyph {
  width: 60%;
  height: 60%;
  background-color: var(--piece-glyph-color);
  mask-image: var(--piece-icon);
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
  -webkit-mask-image: var(--piece-icon);
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  z-index: 1;
}

.piece__content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0;
}

.piece__team-tag {
  position: absolute;
  bottom: -0.4rem;
  right: -0.4rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  background: var(--team-accent, rgba(255, 255, 255, 0.25));
  color: #020617;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.piece__controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  pointer-events: auto;
}

.piece__name {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}

.piece__hp {
  font-size: 0.48rem;
  letter-spacing: 0.04em;
}

.piece:hover,
.piece:focus-visible {
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.5);
}

.piece--selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 160, 67, 0.5), 0 18px 38px rgba(0, 0, 0, 0.55);
  z-index: 20;
}

.piece--buffed::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(250, 204, 21, 0.9);
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.6);
  pointer-events: none;
}

.piece__status {
  position: absolute;
  top: calc(var(--piece-status-offset, -0.08) * var(--piece-size));
  left: 50%;
  transform: translate(-50%, -0.05rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  pointer-events: none;
  width: 100%;
}

.piece__label {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, calc(-100% - 10px));
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  background: rgba(12, 15, 20, 0.75);
  color: rgba(240, 246, 252, 0.9);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  cursor: pointer;
}

.piece__label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.piece__action {
  background: rgba(12, 15, 20, 0.75);
  color: rgba(240, 246, 252, 0.9);
}

.piece--selected .piece__action {
  opacity: 1;
  pointer-events: auto;
}

.piece__end-turn {
  transform: translate(-50%, calc(-100% - 32px));
  background: var(--accent);
  color: var(--fg);
  opacity: 1;
  pointer-events: auto;
}

.piece__end-turn:hover,
.piece__end-turn:focus-visible {
  transform: translate(-50%, calc(-100% - 32px));
}

.piece--controls-bottom .piece__label {
  top: auto;
  bottom: 0;
  left: 50%;
  right: auto;
  transform: translate(-50%, calc(300% + 35px));
}

.piece--controls-bottom .piece__end-turn {
  top: auto;
  bottom: 0;
  transform: translate(-50%, calc(300% + 55px));
}

.piece--controls-bottom .piece__action:hover,
.piece--controls-bottom .piece__action:focus-visible,
.piece--controls-bottom .piece__end-turn:hover,
.piece--controls-bottom .piece__end-turn:focus-visible {
  box-shadow: none;
}

.piece--controls-left .piece__label {
  top: 0;
  bottom: auto;
  left: 0;
  right: auto;
  transform: translate(calc(-100% - 14px), 30px);
}

.piece--controls-left .piece__end-turn {
  top: auto;
  bottom: 0;
  left: 0;
  transform: translate(calc(-100% - 14px), 15px);
}

.piece--controls-left .piece__action:hover,
.piece--controls-left .piece__action:focus-visible,
.piece--controls-left .piece__end-turn:hover,
.piece--controls-left .piece__end-turn:focus-visible {
  box-shadow: none;
}

.piece--controls-right .piece__label {
  top: 0;
  bottom: auto;
  left: auto;
  right: 0;
  transform: translate(calc(100% + 14px), 30px);
}

.piece--controls-right .piece__end-turn {
  top: auto;
  bottom: 0;
  left: auto;
  right: 0;
  transform: translate(calc(100% + 14px), 15px);
}

.piece--controls-right .piece__action:hover,
.piece--controls-right .piece__action:focus-visible,
.piece--controls-right .piece__end-turn:hover,
.piece--controls-right .piece__end-turn:focus-visible {
  box-shadow: none;
}

.piece__hp-bar {
  width: calc(var(--piece-size) * 0.9);
  max-width: 58px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.piece__hp-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #34d399, #059669);
  transition: width 0.2s ease;
}


button:not(.piece):not(.piece__action) {
  padding: 0.75rem 1.75rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--fg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
  white-space: nowrap;
}

button:not(.piece):not(.piece__action):hover,
button:not(.piece):not(.piece__action):focus-visible {
  box-shadow: 0 10px 20px rgba(46, 160, 67, 0.35);
}

button:not(.piece):not(.piece__action):active {
  box-shadow: none;
}
.toast-stack {
  position: fixed;
  right: clamp(1rem, 4vw, 2.5rem);
  bottom: clamp(1rem, 4vw, 2.5rem);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(320px, 80vw);
  z-index: 999;
}

.toast {
  background: rgba(15, 23, 42, 0.9);
  color: var(--fg);
  padding: 0.85rem 1rem;
  border-radius: 0.85rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  font-size: 0.85rem;
  border-left: 4px solid var(--accent);
  opacity: 0;
  transform: translateY(10px);
  animation: toast-in 220ms ease forwards;
}

.toast--warning {
  border-left-color: #facc15;
}

.toast--error {
  border-left-color: #f87171;
}

.toast--info {
  border-left-color: var(--accent);
}

@keyframes toast-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  background: var(--surface);
  color: var(--fg);
  padding: 2rem;
  border-radius: 1rem;
  width: min(90vw, 360px);
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
}

.modal-card--wide {
  width: min(95vw, 520px);
  max-height: 70vh;
  overflow-y: auto;
  text-align: left;
}

.modal-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
}

.modal-card p {
  margin: 0 0 1.5rem;
  font-size: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: center;
}

#restartButton {
  padding: 0.7rem 1.6rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--fg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#restartButton:hover,
#restartButton:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(46, 160, 67, 0.35);
}

#restartButton:active {
  transform: translateY(0);
  box-shadow: none;
}
#restartButton:active,
#closeSettingsButton:active {
  transform: translateY(0);
  box-shadow: none;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-form section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.settings-form h3 {
  margin: 0;
  font-size: 1rem;
  color: rgba(240, 246, 252, 0.85);
}

.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: rgba(240, 246, 252, 0.9);
}

.settings-form input[type="text"],
.settings-form input[type="number"] {
  border-radius: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.4rem 0.6rem;
  background: rgba(15, 23, 42, 0.65);
  color: var(--fg);
}

.settings-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

#closeSettingsButton {
  padding: 0.7rem 1.6rem;
  border: none;
  border-radius: 999px;
  background: rgba(99, 110, 123, 0.4);
  color: var(--fg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

@media (max-width: 1200px), (max-height: 760px) {
  body {
    overflow: auto;
    height: auto;
  }
  #app {
    height: auto;
    min-height: 100vh;
  }

  button {
  white-space: nowrap;
}
}

@media (max-width: 1100px) {
  .drawer-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    letter-spacing: 0.1em;

    
  }

button {
  white-space: nowrap;
}
  .side-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(340px, 80vw);
    max-width: none;
    background: rgba(8, 13, 23, 0.95);
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
    z-index: 900;
    transform: translateX(-110%);
    overflow-y: auto;
  }

  .side-panel--chat {
    left: 0;
  }

  .side-panel--controls {
    right: 0;
    transform: translateX(110%);
  }

  .side-panel--open {
    transform: translateX(0);
  }

  .play-layout {
    justify-content: center;
  }

  .board-wrapper {
    padding: 2.5rem 1.25rem 2rem;
  }
}
