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

body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    background-color: #c0deff; /* Light blue background for outside the frame */
    color: #333;
    touch-action: manipulation;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#game-container {
    margin-top: 60px;
    width: 100%;
    max-width: 480px;
        height: 90vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    position: relative;
    background-color: #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    overflow: hidden;
    border-radius: 10px; /* Slight rounding for a mobile feel */
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* Start / Result Screens */
#start-screen, #result-screen {
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.95);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
}

h1 {
    font-size: 2.5rem;
    color: #ff6b6b;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

p {
    font-size: 1.2rem;
    margin-bottom: 10px;
    text-align: center;
    line-height: 1.5;
}

.timer-text {
    font-weight: bold;
    color: #4ecdc4;
    font-size: 1.5rem;
    margin-bottom: 30px;
}

button {
    background-color: #ff6b6b;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: transform 0.1s, background-color 0.2s;
    margin: 10px;
}

button:active {
    transform: scale(0.95);
}

/* Playing Screen */
#playing-screen {
    justify-content: flex-start;
}

.hud {
    width: 100%;
    padding: 20px 15px;
    display: flex;
    align-items: flex-start;
    background-color: #333;
    color: white;
    font-size: 1rem;
    gap: 29px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    z-index: 10;
    flex-direction: row;
    justify-content: flex-start;
    margin-left: 0; 
    background: linear-gradient(135deg, rgb(196, 113, 245) 0%, rgb(250, 113, 205) 100%);
}

.hud-icon {
    width: 1.2rem;
    height: 1.2rem;
    vertical-align: -0.15em;
    margin-right: 5px;
}

#time-left {
    color: #ffdd59;
}

.timer-bar-container {
    width: 100%;
    height: 8px;
    background-color: #555;
    z-index: 10;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background-color: #4ecdc4;
    transition: width 1s linear, background-color 0.5s ease;
    transform-origin: left;
}

.images-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex-grow: 1;
    padding: 10px;
    gap: 10px;
    overflow: hidden; /* 画像がスクロールしないように設定 */
}

.image-wrapper {
    position: relative;
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: calc(50% - 5px); /* コンテナの半分からギャップ分を引いたサイズを最大値に */
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent;
    flex-shrink: 1; /* 縮小を許可 */
}

.game-image {
    width: 100%;
    height: auto;
    object-fit: fill; /* Since wrapper has aspect ratio, fill is safe */
    border: 3px solid #ccc;
    border-radius: 8px;
    user-select: none;
    -webkit-user-drag: none;
}

/* Layers over the image */
.markers-layer, .differences-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through if needed, except where specified */
}

.differences-layer {
    pointer-events: none;
}

/* Specific Differences (CSS injected shapes/colors) */
.diff-item {
    position: absolute;
    background-size: cover;
}

/* Circle marker for found differences */
.marker-circle {
    position: absolute;
    border: 4px solid #ff4757;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Cross marker for wrong clicks */
.marker-cross {
    position: absolute;
    color: #4ecdc4; /* or #333, red might be confused with the correct circle */
    font-size: 4rem;
    font-weight: bold;
    font-family: sans-serif;
    transform: translate(-50%, -50%);
    pointer-events: none;
    text-shadow: 2px 2px 0px #fff, -2px -2px 0px #fff, 2px -2px 0px #fff, -2px 2px 0px #fff;
    animation: fadeOut 0.8s forwards;
    z-index: 50;
}

@keyframes popIn {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes fadeOut {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    10% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}


/* End of styles */

