* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
:root {
  --field-w: min(80vw, calc(80vh * 860 / 600));
}
body {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: #0d0d1a;
  font-family: system-ui, sans-serif;
}

#app {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#side-panel {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  /* Center the panel within the gap between the game and the right edge. */
  left: clamp(
    calc(50% + 4px),
    calc(75vw + var(--field-w) / 4 - 120px),
    calc(100vw - 248px)
  );
  width: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 600;
}

#home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
#home-container > img {
  width: 300px;
  max-width: 80vw;
}

#pc-notice {
  color: #8888aa;
  font-size: 0.72rem;
  text-align: center;
  padding: 7px 14px;
  border: 1.5px solid #2a2a4a;
  border-radius: 999px;
  background: #1a1a2e;
}

#manual-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 20px 22px;
  background: #1a1a2e;
  border: 2px solid #2a2a4a;
  border-radius: 8px;
}
#manual-title {
  text-align: center;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 2px;
}
.manual-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 10px 12px;
  background: #0d0d1a;
  border: 1.5px solid #2a2a4a;
  border-radius: 6px;
  color: #cfcfdd;
  font-size: 0.8rem;
  line-height: 1.3;
}
.manual-row .keys {
  align-self: flex-end;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  column-gap: 6px;
  row-gap: 8px;
}
.manual-row .keys .or {
  color: #555577;
  font-size: 0.7rem;
}
.manual-row kbd {
  font-family: inherit;
  padding: 2px 6px;
  background: #16161f;
  border: 1.5px solid #3a3a5a;
  border-radius: 4px;
  color: #fff;
  font-size: 0.7rem;
  white-space: nowrap;
}
#logo {
  animation: pulse 2s ease-in-out infinite;
}

#game-container {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 16px;
  border: 1.5px solid #2a2a4a;
  border-radius: 14px;
}

header {
  text-align: center;
}
header p:first-child {
  font-size: 0.7rem;
  color: #555577;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
#score {
  font-size: 1.6rem;
  color: #fff;
  font-weight: 500;
}

/* field: full play area, ball+paddle move freely here */
#field-wrap {
  position: relative;
  width: var(--field-w);
  aspect-ratio: 860 / 600;
  border: 1.5px solid #2a2a4a;
  border-radius: 4px;
  background: #000000;
  overflow: hidden;
}

/* grid: only top ~58% — bricks live here */
#container {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(7, 1fr);
  width: 100%;
  height: 58%;
  gap: 4px;
  padding: 5px;
  position: relative;
}

#ball {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  bottom: 55px;
  left: calc(50% - 7px);
}

#breaker {
  position: absolute;
  width: 120px;
  height: 12px;
  background: #c8c8e8;
  border-radius: 7px;
  bottom: 20px;
  left: calc(50% - 60px);
}

#press-to-play {
  position: absolute;
  /* Center the prompt above the paddle without stretching it across the field. */
  left: 50%;
  top: 75%;
  transform: translateX(-50%);
  width: max-content;
  font-size: 1rem;
  color: #8888aa;
  animation: pulse 2s ease-in-out infinite;
  pointer-events: none;
}

.brick {
  border-radius: 3px;
}
.brick[data-row='1'] {
  background: #e05555;
}
.brick[data-row='2'] {
  background: #e08844;
}
.brick[data-row='3'] {
  background: #d4c044;
}
.brick[data-row='4'] {
  background: #55bb55;
}
.brick[data-row='5'] {
  background: #44aacc;
}
.brick[data-row='6'] {
  background: #6666dd;
}
.brick[data-row='7'] {
  background: #cc55aa;
}

button {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 200px;
  height: 50px;
  border-radius: 25px;
  border: 1.5px solid #2a2a4a;
  color: #cfcfdd;
  font-size: 0.95rem;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.15s;
}
button img {
  height: 20px;
  filter: invert(0.8);
}
button:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: #6666dd;
  transform: scale(1.04);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}
#header-container {
  width: 100%;
  border: 1.5px solid #2a2a4a;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  padding: 8px 0;
  border-radius: 8px;
}
#settings-btn {
  all: unset;
  width: 40px;
  height: 40px;
  margin-left: 20px;
}

#settings-btn:hover {
  scale: 1.05;
  cursor: pointer;
}

#header-left {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
}

#timer {
  all: unset;
  color: white;
  font-size: 1.3rem;
  font-weight: 500;
}

#header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-right: 20px;
}

.heart {
  width: 40px;
  height: 40px;
}

#pause-menu {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  background: #000000;
  width: 190px;
  height: 60%;
  top: 50%;
  left: 50%;
  z-index: 900;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transform: translate(-50%, -50%);
  border: 2px solid grey;
  border-radius: 8px;
  gap: 20px;
}

.menu-row {
  color: white;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1a1a2e;
  border: 1.5px solid #2a2a4a;
  border-radius: 4px;
  padding: 5px;
}

.menu-row button {
  all: unset;
  margin-left: 10px;
  width: 30px;
  height: 30px;
  color: white;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-row:hover {
  scale: 1.04;
  cursor: pointer;
}
#over-container,
#win-container {
  all: unset;
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 18, 0.82);
  z-index: 800;
}

.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: min(90vw, 360px);
  padding: 32px 28px;
  border-radius: 16px;
  background: #12121f;
  border: 1.5px solid #2a2a4a;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  animation: cardIn 0.35s ease-out;
}

.result-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1.5px solid #2a2a4a;
}
.result-icon svg {
  width: 34px;
  height: 34px;
}
.win-card .result-icon {
  color: #6be06b;
  background: rgba(85, 187, 85, 0.12);
  border-color: rgba(85, 187, 85, 0.4);
}
.lose-card .result-icon {
  color: #ff6b6b;
  background: rgba(224, 85, 85, 0.12);
  border-color: rgba(224, 85, 85, 0.4);
}

#over-title,
#win-title {
  all: unset;
  font-size: 1.8rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.1;
  color: #fff;
}
#win-title {
  color: #6be06b;
}
#over-title {
  color: #ff6b6b;
}

.result-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.result-score span {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #555577;
}
.result-score strong {
  font-size: 2.2rem;
  font-weight: 600;
  color: #fff;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.result-actions .menu-row {
  width: 100%;
  justify-content: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.15s;
}
.result-actions .menu-row:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: #6666dd;
}
.result-actions .restart-btn {
  background: #6666dd;
  border-color: #6666dd;
}
.result-actions .restart-btn:hover {
  background: #7a7ae6;
  border-color: #7a7ae6;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

footer {
  all: unset;
  display: block;
  text-align: center;
  color: #8888aa;
  animation: animate 2s ease-in-out infinite;
  will-change: transform;
}

@keyframes animate {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}
