* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f2940, #070814 60%);
  color: #f5f7ff;
  overflow: hidden;
}

/* root container */
.app-root {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

@media (max-width: 768px) {
  .app-root {
    /* 모바일에서 하단 액션바에 가려지지 않도록 전체 높이에서 약간 빼고 중앙 정렬 */
    height: calc(100vh - 64px);
  }
}

.screen {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 960px;
  max-height: 800px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
}

.screen--hidden {
  pointer-events: none;
  opacity: 0;
}

.fade-in {
  animation: fade-in 0.4s ease-out forwards;
}

.fade-out {
  animation: fade-out 0.25s ease-in forwards;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(1.03) translateY(-10px);
  }
}

.btn {
  min-width: 160px;
  padding: 0.75rem 1.5rem;
  margin: 0.5rem 0;
  border-radius: 999px;
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0b0d1a;
  background: linear-gradient(135deg, #ffd86f, #fc6262);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.title-logo {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 2rem;
  color: #ffffff;
  text-shadow: 0 0 16px rgba(0, 255, 255, 0.4);
}

.subtitle {
  font-size: 0.9rem;
  opacity: 0.7;
  margin-bottom: 2rem;
}

.game-layout {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: 1.5rem;
  gap: 1rem;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-header__stats {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
}

.game-board-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-canvas {
  background: radial-gradient(circle at top, #151b2c, #05060c 70%);
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.8);
  max-width: 100%;
  max-height: 100%;
}

.game-blocks {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.block-slot {
  width: 120px;
  height: 120px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-panel,
.ranking-panel {
  padding: 2rem 2.5rem;
  border-radius: 24px;
  background: rgba(4, 6, 18, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.8);
  min-width: 320px;
  max-width: 100%;
}

.result-panel__title,
.ranking-panel__title {
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

.result-panel__row {
  display: flex;
  justify-content: space-between;
  margin: 0.35rem 0;
}

.ranking-list {
  margin-top: 1rem;
  max-height: 260px;
  overflow: hidden;
}

.ranking-item {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  opacity: 0;
  transform: translateY(8px);
}

.ranking-item--me {
  color: #ffd86f;
}

@keyframes ranking-item-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  display: none !important;
}

.hexacube-drag-preview {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
}

/* 모바일 대응: 작은 화면에서 패딩/폰트/블럭 슬롯 줄이기 */
@media (max-width: 768px) {
  .screen {
    max-width: 100%;
    max-height: 100%;
  }

  .game-layout {
    padding: 0.75rem;
    gap: 0.5rem;
    padding-bottom: 3.25rem; /* 모바일에서 하단 여유 더 확보 */
  }

  .game-header__stats {
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
  }

  .block-slot {
    width: 88px;
    height: 88px;
    border-radius: 16px;
  }

  .btn {
    width: 100%;
    max-width: 260px;
  }

  body {
    touch-action: none;
  }
}

.game-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  opacity: 0.9;
}

.game-reset-button {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #63e3ff, #778bff);
  color: #05060c;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.game-reset-button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.game-reset-count {
  min-width: 2rem;
  text-align: left;
  font-weight: 600;
  color: #ffd86f;
}

.game-reset-gauge {
  position: relative;
  flex: 1 1 120px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.game-reset-gauge__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #ffd86f, #ff9f7b);
  transition: width 0.2s ease-out;
}

@media (max-width: 768px) {
  .game-controls {
    gap: 0.5rem;
    font-size: 0.8rem;
  }
  .game-reset-button {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
  }
}