*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1e2433;
  color: #c8d4e8;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  touch-action: none;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  max-height: 100dvh;
}

.hud-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  background: linear-gradient(180deg, #2a3142, #1e2433);
  border-bottom: 1px solid #4a5568;
  flex-shrink: 0;
}

.player-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.28rem 0.4rem;
  font-size: clamp(0.55rem, 1.4vw, 0.76rem);
}

.player-hud-p2 {
  justify-content: flex-end;
  text-align: right;
}

.player-label {
  font-weight: 700;
  color: #6eb5d9;
}

.player-hud-p2 .player-label {
  color: #d98aaa;
}

.remain-count {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 800;
}

.center-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.18rem;
}

.mode-select {
  font-size: clamp(0.55rem, 1.3vw, 0.7rem);
  padding: 0.1rem 0.25rem;
  background: #1e2433;
  color: #c8d4e8;
  border: 1px solid #4a5568;
  border-radius: 4px;
}

.match-status {
  font-size: clamp(0.55rem, 1.4vw, 0.72rem);
  color: #8a96aa;
  text-align: center;
}

.btn-reset {
  padding: 0.14rem 0.45rem;
  font-size: 0.65rem;
  border: 1px solid #4a5568;
  border-radius: 4px;
  background: #2a3142;
  color: #c8d4e8;
  cursor: pointer;
}

.field-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 0.25rem;
  display: flex;
}

.canvas-area {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

#game-canvas {
  width: 100%;
  height: 100%;
  border: 3px solid #4a5568;
  border-radius: 8px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 22, 31, 0.88);
  border-radius: 8px;
  pointer-events: none;
}

.overlay.hidden {
  display: none;
}

#overlay-text {
  font-size: clamp(1rem, 4vw, 1.6rem);
  font-weight: 800;
  color: #e8eef8;
}

.hud-bottom {
  padding: 0.2rem 0.45rem;
  border-top: 1px solid #4a5568;
  flex-shrink: 0;
}

.hint {
  font-size: clamp(0.48rem, 1.2vw, 0.65rem);
  color: #6a7588;
  text-align: center;
}

.hint strong {
  color: #8ab4d4;
}

.layout-mobile-landscape .hud-top {
  padding: 0.22rem 0.35rem;
}

.layout-mobile-landscape .field-wrap {
  padding: 0.15rem;
}

.layout-portrait .hud-top {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
}

.layout-portrait .center-info {
  grid-column: 1 / -1;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2rem;
}

.layout-portrait .player-hud-p1 {
  order: 2;
}

.layout-portrait .player-hud-p2 {
  order: 1;
  justify-content: flex-start;
  text-align: left;
}

.layout-portrait .hud-bottom {
  display: none;
}

@media (orientation: portrait) {
  .layout-pc.layout-horizontal .hud-top {
    grid-template-columns: 1fr;
  }
}

.hidden {
  display: none !important;
}

.auth-gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #1e2433;
}

.auth-card {
  width: min(100%, 380px);
  padding: 1.5rem;
  background: linear-gradient(180deg, #2a3142, #1e2433);
  border: 1px solid #4a5568;
  border-radius: 12px;
  text-align: center;
}

.auth-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.4rem, 4vw, 1.75rem);
  color: #e8eef8;
}

.auth-lead {
  margin: 0 0 1rem;
  color: #9aa8bc;
  font-size: 0.9rem;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  text-align: left;
}

.auth-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: #c8d4e8;
}

.auth-input {
  width: 100%;
  font-size: 1.1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 2px solid #4a5568;
  background: #151a24;
  color: #e8eef8;
  min-height: 48px;
}

.auth-input:focus {
  outline: none;
  border-color: #6eb5d9;
}

.auth-error {
  margin: 0;
  color: #e88a9a;
  font-weight: 600;
  font-size: 0.85rem;
}

.btn-auth-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 0.25rem;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #1e2433;
  background: linear-gradient(180deg, #8ab4d4, #6eb5d9);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.btn-auth-submit:hover {
  filter: brightness(1.05);
}

.btn-logout {
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  color: #9aa8bc;
  background: transparent;
  border: 1px solid #4a5568;
  border-radius: 6px;
  cursor: pointer;
}

.btn-logout:hover {
  color: #c8d4e8;
  border-color: #6a7588;
}
