/* General Body Styles */
body {
    margin: 0;
    font-family: sans-serif;
    overflow: hidden;
    background-color: #ffffff;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Lock the viewport */
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.container {
  height: 100dvh;              /* スマホ対応 */
  display: flex;
  flex-direction: column;      /* 上中下に縦並び */
  justify-content: center;     /* 縦方向中央 */
  align-items: center;         /* 横方向中央 */
}

/* 上下テキスト */
.top-text {
  margin-bottom: 16px;  /* ゲームエリアとの間隔 */
  text-align: center;
  z-index: 10;          /* ゲームより前面に表示 */
}

.bottom-text {
  margin-top: 16px;
  text-align: center;
  z-index: 10;
}
/* App Container */
#app-container {
    min-height: 100dvh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-wrapper {
    position: relative;
}

#game-canvas-container {
    position: absolute;
    transform-origin: top left;
    background-color: #ffffff;
    border-radius: 1.2rem;
    overflow: hidden;
    background: url('../images/concrete.jpg') no-repeat center center / cover;
}

#game-canvas-container.playing {
    background: url('../images/concrete.jpg') no-repeat center center / cover;
}

.screen {
    position: absolute;
    inset: 0;
    z-index: 10;
}

.hidden {
    display: none !important;
}

/* Start Screen */
#start-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.5);
}
#start-screen-content {
    width: 100%;
    padding-top: 28rem;
    padding-bottom: 8.4rem;
    color: #374151;
    background-repeat: no-repeat;
    background-size: cover;
    animation: fade-in 0.3s ease-out forwards;
}
.start-screen-bg-pc {
    background: url('../images/start_bg_pc.png') no-repeat center center / cover;
}
.start-screen-bg-touch {
    background: url('../images/start_bg_sp.png') no-repeat center center / cover;
}
.start-button {
    padding: 1.5rem 4rem;
    background-color: #bf2e2e;
    color: white;
    font-weight: bold;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    font-size: 2.25rem;
    transition: background-color 0.2s, transform 0.1s;
}
.start-button:hover {
    background-color: #dd6060;
}
.start-button:active {
    transform: scale(0.95);
}

@keyframes fade-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Game UI */
#game-ui {
    pointer-events: none; /* Allow clicks/touches to pass through to the canvas */
}

.ui-top {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    justify-content: space-between;
    z-index: 20;
}
.score-container {
    background-color: rgba(0, 0, 0, 0.24);
    padding: 0.5rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: bold;
    color: white;
    height: 3rem;
}
.score-container p {
    position: relative;
    top: -5px;
}
.score-value {
    color: #facc15;
}
.next-shape-container {
    background-color: rgba(0, 0, 0, 0.24);
    width: 7rem;
    height: 7rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}
#next-shape-image {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

/* Touch Controls */
.touch-controls {
    position: absolute;
    bottom: 1rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4rem;
    z-index: 20;
    pointer-events: auto; /* Re-enable pointer events for the controls container */
}
.control-button {
    width: 5rem;
    height: 5rem;
    background-color: rgba(59, 130, 246, 0.8);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: bold;
    border-radius: 9999px;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.control-button img {
    width: 3rem;
    height: 3rem;
    pointer-events: none;
}
.control-button:active {
    background-color: rgba(29, 78, 216, 0.9);
}
.drop-button {
    background-color: rgba(239, 68, 68, 0.8);
    margin-left: 4rem;
}
.drop-button:active {
    background-color: rgba(185, 28, 28, 0.9);
}


/* Game Over Screen */
#game-over-screen {
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}
.game-over-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-image: url("../images/end_bg.png");
    background-repeat: no-repeat;
    background-position: center center; /* 中央寄せ */
    background-size: contain;           /* 画像全体を表示 */
}
.game-over-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 2rem;
}
.game-over-score {
    font-weight: bold;
    margin-bottom: 1.5rem;
}
.game-over-score span:first-child {
    font-size: 6rem;
    letter-spacing: -0.05em;
    color: #f59e0b;
}
.score-unit {
    font-size: 2.25rem;
    margin-left: 1rem;
    color: #ffffff;
}
.game-over-time {
    font-size: 2.25rem;
    font-weight: bold;
    color: #ffffff;
}
.game-over-time span {
    color: #ffffff;
    letter-spacing: 0.05em;
}
.restart-button {
    margin-top: 3rem;
    padding: 1.5rem 4rem;
    background-color: #bf2e2e;
    color: white;
    font-weight: bold;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    font-size: 2.25rem;
    transition: background-color 0.2s, transform 0.1s;
}
.restart-button:hover {
    background-color: #dd6060;
}
.restart-button:active {
    transform: scale(0.95);
}
.text-center {
    text-align: center;
}

#end-overlay {
  display: none; /* 最初は非表示 */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.8); /* 半透明の黒マスク */
  z-index: 9999; /* 画面最前面 */
  justify-content: center;
  align-items: center;
}

#end-overlay .end-message {
  color: #fff;
  font-size: 2rem;
  text-align: center;
  padding: 20px;
  background: rgba(50,50,50,0.9);
  border-radius: 12px;
}