/* =============================================
   Chess Clock — Mobile-first fullscreen layout
   Phone flat on table between two players.
   Entire layout rotated 90° so all text runs
   along the phone's long side — both players
   read it the same way from their seats.
   ============================================= */

.clock-layout {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    background: var(--dc-slate-900);
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* ── Player zones ── */

.clock-player-zone {
    flex: 1;
    position: relative;
    cursor: pointer;
    transition: background-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    min-height: 0;
    overflow: hidden;
}

.clock-zone-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.25rem;
    gap: 0.5rem;
}

.clock-line {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.clock-label-line {
    min-height: 2rem;
}

.clock-player-zone.active {
    background: rgba(249, 115, 22, 0.15);
}

.clock-player-zone.active .clock-time {
    color: var(--dc-orange);
}

.clock-player-zone.expired {
    background: rgba(220, 38, 38, 0.2);
}

.clock-player-zone.expired .clock-time {
    color: var(--dc-danger);
}

.clock-player-zone:active {
    background: rgba(249, 115, 22, 0.3);
}

/* ── Time display ── */

.clock-player-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.875rem, 2vmax, 1.25rem);
    font-weight: 500;
    color: var(--dc-slate-300);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.clock-score-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.clock-player-score {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2.25rem, 7vmax, 4.5rem);
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    color: #fff;
    min-width: 2ch;
}

.clock-time {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(3rem, 8vmax, 6rem);
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    line-height: 1;
    letter-spacing: -0.02em;
    color: #fff;
    transition: color 0.15s ease;
    white-space: nowrap;
}

.clock-delay {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.75rem, 1.5vmax, 1rem);
    color: var(--dc-slate-500);
    font-family: 'Courier New', Courier, monospace;
    white-space: nowrap;
}

.clock-delay.counting {
    color: var(--dc-orange-mid);
}

/* ── Time bar ── */

.clock-time-bar {
    width: min(80%, 20rem);
    max-width: 320px;
    height: 4px;
    background: var(--dc-slate-700);
    border-radius: 2px;
    overflow: hidden;
}

.clock-time-bar-fill {
    height: 100%;
    background: var(--dc-orange);
    border-radius: 2px;
    transition: width 0.1s linear;
}

.clock-player-zone.expired .clock-time-bar-fill {
    background: var(--dc-danger);
}

/* ── Scoreboard strip ── */

.clock-scoreboard {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: clamp(4rem, 10vw, 6rem);
    padding: 0.75rem 0.5rem;
    background: var(--dc-slate-800);
    border-left: 1px solid var(--dc-slate-700);
    border-right: 1px solid var(--dc-slate-700);
    gap: 0.75rem;
}

.clock-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
}

.clock-target-score {
    font-size: clamp(0.9rem, 2vmax, 1.25rem);
    font-weight: 700;
    color: var(--dc-slate-200);
    text-align: center;
    max-width: 8rem;
    line-height: 1.2;
}

/* ── Buttons ── */

.clock-btn {
    border: none;
    border-radius: var(--dc-radius);
    padding: 0.375rem 0.75rem;
    font-size: clamp(0.75rem, 1.5vmax, 0.875rem);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.clock-btn:active {
    transform: scale(0.95);
}

.clock-btn-score {
    background: var(--dc-slate-700);
    color: #fff;
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0.25rem;
    border-radius: 999px;
}

.clock-btn-score:hover {
    background: var(--dc-slate-500);
}

.clock-btn-pause {
    background: var(--dc-orange);
    color: #fff;
}

.clock-btn-pause:hover {
    background: #ea580c;
}

.clock-btn-cancel {
    background: var(--dc-slate-600);
    color: #fff;
}

.clock-btn-cancel:hover {
    background: var(--dc-slate-500);
}

.clock-btn-start {
    background: var(--dc-success);
    color: #fff;
    padding: 0.75rem 2rem;
    font-size: clamp(1rem, 2vmax, 1.25rem);
}

.clock-btn-start:hover {
    background: #047857;
}

/* ── States ── */

.clock-not-started {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.clock-not-started h2 {
    font-size: clamp(1.25rem, 3vmax, 1.75rem);
    font-weight: 600;
    color: var(--dc-slate-300);
}

.clock-finished-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.85);
    z-index: 10;
}

.clock-finished-text {
    font-size: clamp(1.5rem, 4vmax, 2.5rem);
    font-weight: bold;
    color: var(--dc-orange);
    text-align: center;
}

/* ── Setup form ── */

.clock-setup-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: min(90%, 320px);
}

.clock-setup-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.clock-setup-row label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dc-slate-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.clock-setup-row input,
.clock-setup-row select {
    background: var(--dc-slate-800);
    border: 1px solid var(--dc-slate-600);
    border-radius: var(--dc-radius);
    color: #fff;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    font-family: inherit;
}

.clock-setup-row input:focus,
.clock-setup-row select:focus {
    outline: none;
    border-color: var(--dc-orange);
}

.clock-setup-form .clock-btn-start {
    margin-top: 0.5rem;
    align-self: center;
}

.clock-confirm-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.88);
    z-index: 20;
    padding: 1rem;
}

.clock-confirm-panel {
    width: min(90vw, 26rem);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--dc-slate-600);
    border-radius: calc(var(--dc-radius) * 1.5);
    background: var(--dc-slate-800);
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.35);
    text-align: center;
}

.clock-confirm-title {
    font-size: clamp(1.1rem, 2.5vmax, 1.5rem);
    font-weight: 700;
    color: #fff;
}

.clock-confirm-score {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: clamp(1rem, 2.2vmax, 1.25rem);
    color: var(--dc-slate-200);
}

.clock-confirm-error {
    color: #fca5a5;
    font-size: 0.95rem;
}

.clock-confirm-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}
